foundrydb-sdk 0.5.0__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.
- foundrydb/__init__.py +280 -0
- foundrydb/ai_actions.py +242 -0
- foundrydb/app_jobs.py +494 -0
- foundrydb/app_services.py +606 -0
- foundrydb/backups.py +43 -0
- foundrydb/client.py +354 -0
- foundrydb/data_pipelines.py +155 -0
- foundrydb/edge.py +166 -0
- foundrydb/embedding_pipelines.py +415 -0
- foundrydb/file_services.py +333 -0
- foundrydb/inference.py +325 -0
- foundrydb/monitoring.py +117 -0
- foundrydb/organizations.py +76 -0
- foundrydb/queues.py +242 -0
- foundrydb/services.py +286 -0
- foundrydb/types.py +2297 -0
- foundrydb/users.py +47 -0
- foundrydb/vector_search.py +141 -0
- foundrydb/webhooks.py +239 -0
- foundrydb_sdk-0.5.0.dist-info/METADATA +433 -0
- foundrydb_sdk-0.5.0.dist-info/RECORD +23 -0
- foundrydb_sdk-0.5.0.dist-info/WHEEL +4 -0
- foundrydb_sdk-0.5.0.dist-info/licenses/LICENSE +21 -0
foundrydb/__init__.py
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"""
|
|
2
|
+
FoundryDB Python SDK
|
|
3
|
+
====================
|
|
4
|
+
|
|
5
|
+
Official Python client for the FoundryDB managed database platform.
|
|
6
|
+
|
|
7
|
+
Sync usage::
|
|
8
|
+
|
|
9
|
+
from foundrydb import FoundryDB
|
|
10
|
+
|
|
11
|
+
client = FoundryDB(
|
|
12
|
+
api_url="https://api.foundrydb.com",
|
|
13
|
+
username="admin",
|
|
14
|
+
password="admin",
|
|
15
|
+
)
|
|
16
|
+
services = client.services.list()
|
|
17
|
+
|
|
18
|
+
Async usage::
|
|
19
|
+
|
|
20
|
+
import asyncio
|
|
21
|
+
from foundrydb import AsyncFoundryDB
|
|
22
|
+
|
|
23
|
+
async def main():
|
|
24
|
+
async with AsyncFoundryDB(
|
|
25
|
+
api_url="https://api.foundrydb.com",
|
|
26
|
+
username="admin",
|
|
27
|
+
password="admin",
|
|
28
|
+
) as client:
|
|
29
|
+
services = await client.services.list()
|
|
30
|
+
|
|
31
|
+
asyncio.run(main())
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
from .client import FoundryDB, AsyncFoundryDB
|
|
35
|
+
from .types import (
|
|
36
|
+
DatabaseType,
|
|
37
|
+
CreateServiceRequest,
|
|
38
|
+
FoundryDBError,
|
|
39
|
+
Organization,
|
|
40
|
+
Service,
|
|
41
|
+
ServicePreset,
|
|
42
|
+
DNSRecord,
|
|
43
|
+
DatabaseUser,
|
|
44
|
+
RevealPasswordResponse,
|
|
45
|
+
Backup,
|
|
46
|
+
TriggerBackupResponse,
|
|
47
|
+
ServiceMetrics,
|
|
48
|
+
LogsTaskResponse,
|
|
49
|
+
LogsResultResponse,
|
|
50
|
+
AppContainerConfig,
|
|
51
|
+
AppDeployStep,
|
|
52
|
+
AppDeployment,
|
|
53
|
+
AppService,
|
|
54
|
+
ServiceAttachment,
|
|
55
|
+
SmtpConfig,
|
|
56
|
+
AuthTheme,
|
|
57
|
+
IdpProviderRequest,
|
|
58
|
+
IdpProviderConfig,
|
|
59
|
+
AuthEnableRequest,
|
|
60
|
+
AuthConfiguration,
|
|
61
|
+
AuthSigningKey,
|
|
62
|
+
AuthConfigurationWithKeys,
|
|
63
|
+
EdgeDomain,
|
|
64
|
+
EdgeDomainStatus,
|
|
65
|
+
EdgeCacheRule,
|
|
66
|
+
EdgeRateLimit,
|
|
67
|
+
EdgeRateLimitKey,
|
|
68
|
+
EdgeWAFMode,
|
|
69
|
+
EdgeAppApplication,
|
|
70
|
+
EdgeStatus,
|
|
71
|
+
EdgeSettings,
|
|
72
|
+
# App Jobs
|
|
73
|
+
AppJob,
|
|
74
|
+
AppJobInvocation,
|
|
75
|
+
AppJobLogLines,
|
|
76
|
+
AppJobInvocationLogs,
|
|
77
|
+
# Queues
|
|
78
|
+
Queue,
|
|
79
|
+
QueueEnqueueMessageIDs,
|
|
80
|
+
QueueEnqueueResult,
|
|
81
|
+
QueueStats,
|
|
82
|
+
QueueStatsResult,
|
|
83
|
+
# File Services
|
|
84
|
+
FilesBucket,
|
|
85
|
+
FilesConfig,
|
|
86
|
+
FilesService,
|
|
87
|
+
FilesAccessKey,
|
|
88
|
+
FilesAccessKeyWithSecret,
|
|
89
|
+
FilesPresignedURL,
|
|
90
|
+
FilesObject,
|
|
91
|
+
FilesObjectPage,
|
|
92
|
+
# Inference
|
|
93
|
+
InferenceProviderConfig,
|
|
94
|
+
InferenceKey,
|
|
95
|
+
CreateInferenceKeyResult,
|
|
96
|
+
OrgInferenceSettings,
|
|
97
|
+
InferenceUsageRow,
|
|
98
|
+
InferenceUsageSummary,
|
|
99
|
+
# Webhooks / Events
|
|
100
|
+
WebhookEndpoint,
|
|
101
|
+
WebhookDelivery,
|
|
102
|
+
Event,
|
|
103
|
+
EventPage,
|
|
104
|
+
# Data Pipelines
|
|
105
|
+
DataPipelineConfig,
|
|
106
|
+
DataPipeline,
|
|
107
|
+
DataPipelineStatus,
|
|
108
|
+
# Embedding Pipelines
|
|
109
|
+
EmbeddingPipelineMode,
|
|
110
|
+
EmbeddingPipeline,
|
|
111
|
+
EmbeddingRunErrorSample,
|
|
112
|
+
EmbeddingPipelineRun,
|
|
113
|
+
# Vector Search
|
|
114
|
+
VectorSearchMetric,
|
|
115
|
+
VectorSearchFilter,
|
|
116
|
+
VectorSearchColumn,
|
|
117
|
+
VectorSearchResponse,
|
|
118
|
+
# AI Actions
|
|
119
|
+
AIActionRef,
|
|
120
|
+
AIActionItem,
|
|
121
|
+
AIActionsResponse,
|
|
122
|
+
CopilotStep,
|
|
123
|
+
CopilotPlan,
|
|
124
|
+
ExecuteAIActionResult,
|
|
125
|
+
AIActionExecution,
|
|
126
|
+
AIActionExecutionListResponse,
|
|
127
|
+
AIActionRollbackResult,
|
|
128
|
+
)
|
|
129
|
+
from .services import ServicesAPI, AsyncServicesAPI
|
|
130
|
+
from .users import UsersAPI, AsyncUsersAPI
|
|
131
|
+
from .backups import BackupsAPI, AsyncBackupsAPI
|
|
132
|
+
from .monitoring import MonitoringAPI, AsyncMonitoringAPI
|
|
133
|
+
from .organizations import OrganizationsAPI, AsyncOrganizationsAPI
|
|
134
|
+
from .app_services import AppServicesAPI, AsyncAppServicesAPI
|
|
135
|
+
from .edge import EdgeAPI, AsyncEdgeAPI
|
|
136
|
+
from .app_jobs import AppJobsAPI, AsyncAppJobsAPI
|
|
137
|
+
from .queues import QueuesAPI, AsyncQueuesAPI
|
|
138
|
+
from .file_services import FileServicesAPI, AsyncFileServicesAPI
|
|
139
|
+
from .inference import InferenceAPI, AsyncInferenceAPI
|
|
140
|
+
from .webhooks import WebhooksAPI, AsyncWebhooksAPI
|
|
141
|
+
from .data_pipelines import DataPipelinesAPI, AsyncDataPipelinesAPI
|
|
142
|
+
from .embedding_pipelines import EmbeddingPipelinesAPI, AsyncEmbeddingPipelinesAPI
|
|
143
|
+
from .vector_search import VectorSearchAPI, AsyncVectorSearchAPI
|
|
144
|
+
from .ai_actions import AIActionsAPI, AsyncAIActionsAPI
|
|
145
|
+
|
|
146
|
+
__version__ = "0.4.0"
|
|
147
|
+
__all__ = [
|
|
148
|
+
# Clients
|
|
149
|
+
"FoundryDB",
|
|
150
|
+
"AsyncFoundryDB",
|
|
151
|
+
# Core types
|
|
152
|
+
"DatabaseType",
|
|
153
|
+
"CreateServiceRequest",
|
|
154
|
+
"FoundryDBError",
|
|
155
|
+
"Organization",
|
|
156
|
+
"Service",
|
|
157
|
+
"ServicePreset",
|
|
158
|
+
"DNSRecord",
|
|
159
|
+
"DatabaseUser",
|
|
160
|
+
"RevealPasswordResponse",
|
|
161
|
+
"Backup",
|
|
162
|
+
"TriggerBackupResponse",
|
|
163
|
+
"ServiceMetrics",
|
|
164
|
+
"LogsTaskResponse",
|
|
165
|
+
"LogsResultResponse",
|
|
166
|
+
# App Services types
|
|
167
|
+
"AppContainerConfig",
|
|
168
|
+
"AppDeployStep",
|
|
169
|
+
"AppDeployment",
|
|
170
|
+
"AppService",
|
|
171
|
+
"ServiceAttachment",
|
|
172
|
+
"SmtpConfig",
|
|
173
|
+
"AuthTheme",
|
|
174
|
+
"IdpProviderRequest",
|
|
175
|
+
"IdpProviderConfig",
|
|
176
|
+
"AuthEnableRequest",
|
|
177
|
+
"AuthConfiguration",
|
|
178
|
+
"AuthSigningKey",
|
|
179
|
+
"AuthConfigurationWithKeys",
|
|
180
|
+
# Edge types
|
|
181
|
+
"EdgeDomain",
|
|
182
|
+
"EdgeDomainStatus",
|
|
183
|
+
"EdgeCacheRule",
|
|
184
|
+
"EdgeRateLimit",
|
|
185
|
+
"EdgeRateLimitKey",
|
|
186
|
+
"EdgeWAFMode",
|
|
187
|
+
"EdgeAppApplication",
|
|
188
|
+
"EdgeStatus",
|
|
189
|
+
"EdgeSettings",
|
|
190
|
+
# App Jobs types
|
|
191
|
+
"AppJob",
|
|
192
|
+
"AppJobInvocation",
|
|
193
|
+
"AppJobLogLines",
|
|
194
|
+
"AppJobInvocationLogs",
|
|
195
|
+
# Queue types
|
|
196
|
+
"Queue",
|
|
197
|
+
"QueueEnqueueMessageIDs",
|
|
198
|
+
"QueueEnqueueResult",
|
|
199
|
+
"QueueStats",
|
|
200
|
+
"QueueStatsResult",
|
|
201
|
+
# File Services types
|
|
202
|
+
"FilesBucket",
|
|
203
|
+
"FilesConfig",
|
|
204
|
+
"FilesService",
|
|
205
|
+
"FilesAccessKey",
|
|
206
|
+
"FilesAccessKeyWithSecret",
|
|
207
|
+
"FilesPresignedURL",
|
|
208
|
+
"FilesObject",
|
|
209
|
+
"FilesObjectPage",
|
|
210
|
+
# Inference types
|
|
211
|
+
"InferenceProviderConfig",
|
|
212
|
+
"InferenceKey",
|
|
213
|
+
"CreateInferenceKeyResult",
|
|
214
|
+
"OrgInferenceSettings",
|
|
215
|
+
"InferenceUsageRow",
|
|
216
|
+
"InferenceUsageSummary",
|
|
217
|
+
# Webhook / Event types
|
|
218
|
+
"WebhookEndpoint",
|
|
219
|
+
"WebhookDelivery",
|
|
220
|
+
"Event",
|
|
221
|
+
"EventPage",
|
|
222
|
+
# Data Pipeline types
|
|
223
|
+
"DataPipelineConfig",
|
|
224
|
+
"DataPipeline",
|
|
225
|
+
"DataPipelineStatus",
|
|
226
|
+
# Embedding Pipeline types
|
|
227
|
+
"EmbeddingPipelineMode",
|
|
228
|
+
"EmbeddingPipeline",
|
|
229
|
+
"EmbeddingRunErrorSample",
|
|
230
|
+
"EmbeddingPipelineRun",
|
|
231
|
+
# Vector Search types
|
|
232
|
+
"VectorSearchMetric",
|
|
233
|
+
"VectorSearchFilter",
|
|
234
|
+
"VectorSearchColumn",
|
|
235
|
+
"VectorSearchResponse",
|
|
236
|
+
# AI Actions types
|
|
237
|
+
"AIActionRef",
|
|
238
|
+
"AIActionItem",
|
|
239
|
+
"AIActionsResponse",
|
|
240
|
+
"CopilotStep",
|
|
241
|
+
"CopilotPlan",
|
|
242
|
+
"ExecuteAIActionResult",
|
|
243
|
+
"AIActionExecution",
|
|
244
|
+
"AIActionExecutionListResponse",
|
|
245
|
+
"AIActionRollbackResult",
|
|
246
|
+
# API classes (sync)
|
|
247
|
+
"ServicesAPI",
|
|
248
|
+
"UsersAPI",
|
|
249
|
+
"BackupsAPI",
|
|
250
|
+
"MonitoringAPI",
|
|
251
|
+
"OrganizationsAPI",
|
|
252
|
+
"AppServicesAPI",
|
|
253
|
+
"EdgeAPI",
|
|
254
|
+
"AppJobsAPI",
|
|
255
|
+
"QueuesAPI",
|
|
256
|
+
"FileServicesAPI",
|
|
257
|
+
"InferenceAPI",
|
|
258
|
+
"WebhooksAPI",
|
|
259
|
+
"DataPipelinesAPI",
|
|
260
|
+
"EmbeddingPipelinesAPI",
|
|
261
|
+
"VectorSearchAPI",
|
|
262
|
+
"AIActionsAPI",
|
|
263
|
+
# API classes (async)
|
|
264
|
+
"AsyncServicesAPI",
|
|
265
|
+
"AsyncUsersAPI",
|
|
266
|
+
"AsyncBackupsAPI",
|
|
267
|
+
"AsyncMonitoringAPI",
|
|
268
|
+
"AsyncOrganizationsAPI",
|
|
269
|
+
"AsyncAppServicesAPI",
|
|
270
|
+
"AsyncEdgeAPI",
|
|
271
|
+
"AsyncAppJobsAPI",
|
|
272
|
+
"AsyncQueuesAPI",
|
|
273
|
+
"AsyncFileServicesAPI",
|
|
274
|
+
"AsyncInferenceAPI",
|
|
275
|
+
"AsyncWebhooksAPI",
|
|
276
|
+
"AsyncDataPipelinesAPI",
|
|
277
|
+
"AsyncEmbeddingPipelinesAPI",
|
|
278
|
+
"AsyncVectorSearchAPI",
|
|
279
|
+
"AsyncAIActionsAPI",
|
|
280
|
+
]
|
foundrydb/ai_actions.py
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"""
|
|
2
|
+
FoundryDB SDK - AI Actions API (sync and async).
|
|
3
|
+
|
|
4
|
+
Three surfaces:
|
|
5
|
+
1. Feed - a prioritized list of platform-generated recommendations across the
|
|
6
|
+
caller's services (index suggestions, advisories).
|
|
7
|
+
2. Copilot - turns a natural-language intent into a previewable plan without
|
|
8
|
+
executing anything.
|
|
9
|
+
3. Executor - executes one confirm-tier action by delegating to the existing
|
|
10
|
+
brokered, audited handler. Destructive (typed_confirm) actions are
|
|
11
|
+
intentionally excluded and must be executed through the service's native
|
|
12
|
+
API.
|
|
13
|
+
"""
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from typing import Any, Dict, List, Optional
|
|
17
|
+
|
|
18
|
+
from .client import HTTPClient, AsyncHTTPClient
|
|
19
|
+
from .types import (
|
|
20
|
+
AIActionsResponse,
|
|
21
|
+
CopilotPlan,
|
|
22
|
+
ExecuteAIActionResult,
|
|
23
|
+
AIActionExecutionListResponse,
|
|
24
|
+
AIActionRollbackResult,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class AIActionsAPI:
|
|
29
|
+
"""AI Actions feed, copilot, and execution surfaces (sync)."""
|
|
30
|
+
|
|
31
|
+
def __init__(self, http: HTTPClient) -> None:
|
|
32
|
+
self._http = http
|
|
33
|
+
|
|
34
|
+
def list(
|
|
35
|
+
self,
|
|
36
|
+
*,
|
|
37
|
+
service_id: str = "",
|
|
38
|
+
kind: str = "",
|
|
39
|
+
severity: str = "",
|
|
40
|
+
limit: int = 0,
|
|
41
|
+
) -> AIActionsResponse:
|
|
42
|
+
"""Return the prioritized AI actions feed across the caller's services.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
service_id: Filter to one service. Must be visible to the caller.
|
|
46
|
+
kind: ``"index"`` or ``"advisory"``.
|
|
47
|
+
severity: Minimum severity: ``"info"``, ``"warning"``, or
|
|
48
|
+
``"critical"``.
|
|
49
|
+
limit: Max items to return (server default 50, max 200).
|
|
50
|
+
"""
|
|
51
|
+
params: Dict[str, Any] = {}
|
|
52
|
+
if service_id:
|
|
53
|
+
params["service_id"] = service_id
|
|
54
|
+
if kind:
|
|
55
|
+
params["kind"] = kind
|
|
56
|
+
if severity:
|
|
57
|
+
params["severity"] = severity
|
|
58
|
+
if limit > 0:
|
|
59
|
+
params["limit"] = limit
|
|
60
|
+
data = self._http.get("/ai/actions", params=params or None)
|
|
61
|
+
return AIActionsResponse.from_dict(data)
|
|
62
|
+
|
|
63
|
+
def copilot_plan(
|
|
64
|
+
self,
|
|
65
|
+
*,
|
|
66
|
+
intent: str,
|
|
67
|
+
service_id: str = "",
|
|
68
|
+
) -> CopilotPlan:
|
|
69
|
+
"""Turn a natural-language intent into a previewable plan.
|
|
70
|
+
|
|
71
|
+
The plan executes nothing. The server returns 501 when no model
|
|
72
|
+
provider is configured for the organization.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
intent: The natural-language intent to plan for.
|
|
76
|
+
service_id: Optional context service. Must be visible to the
|
|
77
|
+
caller.
|
|
78
|
+
"""
|
|
79
|
+
body: Dict[str, Any] = {"intent": intent}
|
|
80
|
+
if service_id:
|
|
81
|
+
body["service_id"] = service_id
|
|
82
|
+
data = self._http.post("/ai/copilot/plan", body)
|
|
83
|
+
return CopilotPlan.from_dict(data)
|
|
84
|
+
|
|
85
|
+
def execute(
|
|
86
|
+
self,
|
|
87
|
+
*,
|
|
88
|
+
action_type: str,
|
|
89
|
+
service_id: str,
|
|
90
|
+
args: Optional[Dict[str, Any]] = None,
|
|
91
|
+
confirm: bool = True,
|
|
92
|
+
) -> ExecuteAIActionResult:
|
|
93
|
+
"""Execute one confirm-tier action by delegating to its brokered handler.
|
|
94
|
+
|
|
95
|
+
``confirm`` must be ``True``; unknown or destructive (typed_confirm)
|
|
96
|
+
action types are rejected by the server. When the gate accepts and
|
|
97
|
+
delegates, inspect ``status`` and ``http_status`` on the result for
|
|
98
|
+
the inner handler's real outcome.
|
|
99
|
+
|
|
100
|
+
Supported confirm-tier action types in v1:
|
|
101
|
+
- ``apply_index_recommendation``: args ``recommendation_id``
|
|
102
|
+
- ``dismiss_advisory``: args ``advisory_match_id``, ``reason``
|
|
103
|
+
- ``scale_service``: args ``target_plan_name`` or ``cpu_cores`` +
|
|
104
|
+
``memory_mb``; optional ``storage_mb``
|
|
105
|
+
- ``add_replica``: args ``node_name``, ``zone``; optional
|
|
106
|
+
``cpu_cores``, ``memory_mb``, ``storage_mb``
|
|
107
|
+
|
|
108
|
+
Args:
|
|
109
|
+
action_type: The confirm-tier action type to execute.
|
|
110
|
+
service_id: ID of the service the action targets.
|
|
111
|
+
args: Action-specific arguments.
|
|
112
|
+
confirm: Must be ``True`` for confirm-tier actions.
|
|
113
|
+
"""
|
|
114
|
+
body: Dict[str, Any] = {
|
|
115
|
+
"action_type": action_type,
|
|
116
|
+
"service_id": service_id,
|
|
117
|
+
"confirm": confirm,
|
|
118
|
+
}
|
|
119
|
+
if args is not None:
|
|
120
|
+
body["args"] = args
|
|
121
|
+
data = self._http.post("/ai/actions/execute", body)
|
|
122
|
+
return ExecuteAIActionResult.from_dict(data)
|
|
123
|
+
|
|
124
|
+
def list_executions(
|
|
125
|
+
self,
|
|
126
|
+
*,
|
|
127
|
+
service_id: str = "",
|
|
128
|
+
limit: int = 0,
|
|
129
|
+
) -> AIActionExecutionListResponse:
|
|
130
|
+
"""Return the outcome-loop execution history, newest first.
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
service_id: Filter to one service. Must be visible to the caller.
|
|
134
|
+
limit: Max records (server default 50, max 200).
|
|
135
|
+
"""
|
|
136
|
+
params: Dict[str, Any] = {}
|
|
137
|
+
if service_id:
|
|
138
|
+
params["service_id"] = service_id
|
|
139
|
+
if limit > 0:
|
|
140
|
+
params["limit"] = limit
|
|
141
|
+
data = self._http.get("/ai/actions/executions", params=params or None)
|
|
142
|
+
return AIActionExecutionListResponse.from_dict(data)
|
|
143
|
+
|
|
144
|
+
def rollback_execution(self, execution_id: str) -> AIActionRollbackResult:
|
|
145
|
+
"""Reverse a reversible execution.
|
|
146
|
+
|
|
147
|
+
Reversibility is decided by the recorded action type:
|
|
148
|
+
- ``apply_index_recommendation``: drops the created index (async,
|
|
149
|
+
``revert_status`` is ``"requested"``).
|
|
150
|
+
- ``dismiss_advisory``: reactivates the advisory (sync, ``"done"``).
|
|
151
|
+
- ``scale_service`` and ``add_replica``: not reversible (422).
|
|
152
|
+
|
|
153
|
+
The server returns 404 when the execution is not found or its service
|
|
154
|
+
is not visible to the caller.
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
execution_id: ID of the execution to roll back.
|
|
158
|
+
"""
|
|
159
|
+
data = self._http.post(f"/ai/actions/executions/{execution_id}/rollback")
|
|
160
|
+
return AIActionRollbackResult.from_dict(data)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
class AsyncAIActionsAPI:
|
|
164
|
+
"""AI Actions feed, copilot, and execution surfaces (async)."""
|
|
165
|
+
|
|
166
|
+
def __init__(self, http: AsyncHTTPClient) -> None:
|
|
167
|
+
self._http = http
|
|
168
|
+
|
|
169
|
+
async def list(
|
|
170
|
+
self,
|
|
171
|
+
*,
|
|
172
|
+
service_id: str = "",
|
|
173
|
+
kind: str = "",
|
|
174
|
+
severity: str = "",
|
|
175
|
+
limit: int = 0,
|
|
176
|
+
) -> AIActionsResponse:
|
|
177
|
+
"""Return the prioritized AI actions feed across the caller's services."""
|
|
178
|
+
params: Dict[str, Any] = {}
|
|
179
|
+
if service_id:
|
|
180
|
+
params["service_id"] = service_id
|
|
181
|
+
if kind:
|
|
182
|
+
params["kind"] = kind
|
|
183
|
+
if severity:
|
|
184
|
+
params["severity"] = severity
|
|
185
|
+
if limit > 0:
|
|
186
|
+
params["limit"] = limit
|
|
187
|
+
data = await self._http.get("/ai/actions", params=params or None)
|
|
188
|
+
return AIActionsResponse.from_dict(data)
|
|
189
|
+
|
|
190
|
+
async def copilot_plan(
|
|
191
|
+
self,
|
|
192
|
+
*,
|
|
193
|
+
intent: str,
|
|
194
|
+
service_id: str = "",
|
|
195
|
+
) -> CopilotPlan:
|
|
196
|
+
"""Turn a natural-language intent into a previewable plan."""
|
|
197
|
+
body: Dict[str, Any] = {"intent": intent}
|
|
198
|
+
if service_id:
|
|
199
|
+
body["service_id"] = service_id
|
|
200
|
+
data = await self._http.post("/ai/copilot/plan", body)
|
|
201
|
+
return CopilotPlan.from_dict(data)
|
|
202
|
+
|
|
203
|
+
async def execute(
|
|
204
|
+
self,
|
|
205
|
+
*,
|
|
206
|
+
action_type: str,
|
|
207
|
+
service_id: str,
|
|
208
|
+
args: Optional[Dict[str, Any]] = None,
|
|
209
|
+
confirm: bool = True,
|
|
210
|
+
) -> ExecuteAIActionResult:
|
|
211
|
+
"""Execute one confirm-tier action."""
|
|
212
|
+
body: Dict[str, Any] = {
|
|
213
|
+
"action_type": action_type,
|
|
214
|
+
"service_id": service_id,
|
|
215
|
+
"confirm": confirm,
|
|
216
|
+
}
|
|
217
|
+
if args is not None:
|
|
218
|
+
body["args"] = args
|
|
219
|
+
data = await self._http.post("/ai/actions/execute", body)
|
|
220
|
+
return ExecuteAIActionResult.from_dict(data)
|
|
221
|
+
|
|
222
|
+
async def list_executions(
|
|
223
|
+
self,
|
|
224
|
+
*,
|
|
225
|
+
service_id: str = "",
|
|
226
|
+
limit: int = 0,
|
|
227
|
+
) -> AIActionExecutionListResponse:
|
|
228
|
+
"""Return the outcome-loop execution history, newest first."""
|
|
229
|
+
params: Dict[str, Any] = {}
|
|
230
|
+
if service_id:
|
|
231
|
+
params["service_id"] = service_id
|
|
232
|
+
if limit > 0:
|
|
233
|
+
params["limit"] = limit
|
|
234
|
+
data = await self._http.get("/ai/actions/executions", params=params or None)
|
|
235
|
+
return AIActionExecutionListResponse.from_dict(data)
|
|
236
|
+
|
|
237
|
+
async def rollback_execution(self, execution_id: str) -> AIActionRollbackResult:
|
|
238
|
+
"""Reverse a reversible execution."""
|
|
239
|
+
data = await self._http.post(
|
|
240
|
+
f"/ai/actions/executions/{execution_id}/rollback"
|
|
241
|
+
)
|
|
242
|
+
return AIActionRollbackResult.from_dict(data)
|