codemie-sdk-python 0.1.204__py3-none-any.whl → 0.1.230__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.

Potentially problematic release.


This version of codemie-sdk-python might be problematic. Click here for more details.

@@ -0,0 +1,364 @@
1
+ """Vendor service implementation for managing cloud vendor assistant settings."""
2
+
3
+ from typing import Union, Optional, List
4
+
5
+ from ..models.vendor_assistant import (
6
+ VendorType,
7
+ VendorAssistantSettingsResponse,
8
+ VendorAssistantsResponse,
9
+ VendorAssistant,
10
+ VendorAssistantVersion,
11
+ VendorAssistantAliasesResponse,
12
+ VendorAssistantInstallRequest,
13
+ VendorAssistantInstallResponse,
14
+ VendorAssistantUninstallResponse,
15
+ )
16
+ from ..utils import ApiRequestHandler
17
+
18
+
19
+ class VendorAssistantService:
20
+ """Service for managing cloud vendor assistant settings (AWS, Azure, GCP)."""
21
+
22
+ def __init__(self, api_domain: str, token: str, verify_ssl: bool = True):
23
+ """Initialize the vendor service.
24
+
25
+ Args:
26
+ api_domain: Base URL for the CodeMie API
27
+ token: Authentication token
28
+ verify_ssl: Whether to verify SSL certificates
29
+ """
30
+ self._api = ApiRequestHandler(api_domain, token, verify_ssl)
31
+
32
+ def get_assistant_settings(
33
+ self,
34
+ vendor: Union[VendorType, str],
35
+ page: int = 0,
36
+ per_page: int = 10,
37
+ ) -> VendorAssistantSettingsResponse:
38
+ """Get assistant settings for a specific cloud vendor.
39
+
40
+ Args:
41
+ vendor: Cloud vendor type (aws, azure, gcp). Can be VendorType enum or string.
42
+ page: Page number for pagination (0-based)
43
+ per_page: Number of items per page
44
+
45
+ Returns:
46
+ VendorAssistantSettingsResponse containing list of settings and pagination info
47
+
48
+ Example:
49
+ >>> # Using enum
50
+ >>> settings = client.vendor_assistants.get_assistant_settings(VendorType.AWS, page=0, per_page=10)
51
+ >>> # Using string
52
+ >>> settings = client.vendor_assistants.get_assistant_settings("aws", page=0, per_page=10)
53
+ """
54
+ # Convert enum to string value if needed
55
+ vendor_str = vendor.value if isinstance(vendor, VendorType) else vendor
56
+
57
+ params = {
58
+ "page": page,
59
+ "per_page": per_page,
60
+ }
61
+
62
+ return self._api.get(
63
+ f"/v1/vendors/{vendor_str}/assistants/settings",
64
+ VendorAssistantSettingsResponse,
65
+ params=params,
66
+ wrap_response=False,
67
+ )
68
+
69
+ def get_assistants(
70
+ self,
71
+ vendor: Union[VendorType, str],
72
+ setting_id: str,
73
+ per_page: int = 10,
74
+ next_token: Optional[str] = None,
75
+ ) -> VendorAssistantsResponse:
76
+ """Get assistants for a specific vendor setting.
77
+
78
+ Args:
79
+ vendor: Cloud vendor type (aws, azure, gcp). Can be VendorType enum or string.
80
+ setting_id: ID of the vendor setting to retrieve assistants for
81
+ per_page: Number of items per page
82
+ next_token: Token for pagination (optional, for retrieving next page)
83
+
84
+ Returns:
85
+ VendorAssistantsResponse containing list of assistants and pagination token
86
+
87
+ Example:
88
+ >>> # Get first page
89
+ >>> assistants = client.vendor_assistants.get_assistants(
90
+ ... vendor=VendorType.AWS,
91
+ ... setting_id="cac90788-39b7-4ffe-8b57-e8b047fa1f6c",
92
+ ... per_page=8
93
+ ... )
94
+ >>> # Get next page if available
95
+ >>> if assistants.pagination.next_token:
96
+ ... next_page = client.vendor_assistants.get_assistants(
97
+ ... vendor=VendorType.AWS,
98
+ ... setting_id="cac90788-39b7-4ffe-8b57-e8b047fa1f6c",
99
+ ... per_page=8,
100
+ ... next_token=assistants.pagination.next_token
101
+ ... )
102
+ """
103
+ # Convert enum to string value if needed
104
+ vendor_str = vendor.value if isinstance(vendor, VendorType) else vendor
105
+
106
+ params = {
107
+ "setting_id": setting_id,
108
+ "per_page": per_page,
109
+ }
110
+
111
+ if next_token:
112
+ params["next_token"] = next_token
113
+
114
+ return self._api.get(
115
+ f"/v1/vendors/{vendor_str}/assistants",
116
+ VendorAssistantsResponse,
117
+ params=params,
118
+ wrap_response=False,
119
+ )
120
+
121
+ def get_assistant(
122
+ self,
123
+ vendor: Union[VendorType, str],
124
+ assistant_id: str,
125
+ setting_id: str,
126
+ ) -> VendorAssistant:
127
+ """Get a specific assistant by ID for a vendor setting.
128
+
129
+ Args:
130
+ vendor: Cloud vendor type (aws, azure, gcp). Can be VendorType enum or string.
131
+ assistant_id: ID of the assistant to retrieve
132
+ setting_id: ID of the vendor setting
133
+
134
+ Returns:
135
+ VendorAssistant containing assistant details
136
+
137
+ Example:
138
+ >>> assistant = client.vendor_assistants.get_assistant(
139
+ ... vendor=VendorType.AWS,
140
+ ... assistant_id="TJBKR0DGWT",
141
+ ... setting_id="cac90788-39b7-4ffe-8b57-e8b047fa1f6c"
142
+ ... )
143
+ >>> print(f"Name: {assistant.name}, Status: {assistant.status}")
144
+ """
145
+ # Convert enum to string value if needed
146
+ vendor_str = vendor.value if isinstance(vendor, VendorType) else vendor
147
+
148
+ params = {
149
+ "setting_id": setting_id,
150
+ }
151
+
152
+ return self._api.get(
153
+ f"/v1/vendors/{vendor_str}/assistants/{assistant_id}",
154
+ VendorAssistant,
155
+ params=params,
156
+ wrap_response=False,
157
+ )
158
+
159
+ def get_assistant_version(
160
+ self,
161
+ vendor: Union[VendorType, str],
162
+ assistant_id: str,
163
+ version: str,
164
+ setting_id: str,
165
+ ) -> VendorAssistantVersion:
166
+ """Get a specific version of a vendor assistant with detailed information.
167
+
168
+ Args:
169
+ vendor: Cloud vendor type (aws, azure, gcp). Can be VendorType enum or string.
170
+ assistant_id: ID of the assistant to retrieve
171
+ version: Version number to retrieve (e.g., "1", "DRAFT")
172
+ setting_id: ID of the vendor setting
173
+
174
+ Returns:
175
+ VendorAssistantVersion containing detailed version information including
176
+ instruction, foundation model, and timestamps
177
+
178
+ Example:
179
+ >>> version_details = client.vendor_assistants.get_assistant_version(
180
+ ... vendor=VendorType.AWS,
181
+ ... assistant_id="TJBKR0DGWT",
182
+ ... version="1",
183
+ ... setting_id="cac90788-39b7-4ffe-8b57-e8b047fa1f6c"
184
+ ... )
185
+ >>> print(f"Name: {version_details.name}")
186
+ >>> print(f"Version: {version_details.version}")
187
+ >>> print(f"Instruction: {version_details.instruction}")
188
+ >>> print(f"Model: {version_details.foundationModel}")
189
+ """
190
+ # Convert enum to string value if needed
191
+ vendor_str = vendor.value if isinstance(vendor, VendorType) else vendor
192
+
193
+ params = {
194
+ "setting_id": setting_id,
195
+ }
196
+
197
+ return self._api.get(
198
+ f"/v1/vendors/{vendor_str}/assistants/{assistant_id}/{version}",
199
+ VendorAssistantVersion,
200
+ params=params,
201
+ wrap_response=False,
202
+ )
203
+
204
+ def get_assistant_aliases(
205
+ self,
206
+ vendor: Union[VendorType, str],
207
+ assistant_id: str,
208
+ setting_id: str,
209
+ per_page: int = 10,
210
+ next_token: Optional[str] = None,
211
+ ) -> VendorAssistantAliasesResponse:
212
+ """Get aliases for a specific vendor assistant.
213
+
214
+ Args:
215
+ vendor: Cloud vendor type (aws, azure, gcp). Can be VendorType enum or string.
216
+ assistant_id: ID of the assistant to retrieve aliases for
217
+ setting_id: ID of the vendor setting
218
+ per_page: Number of items per page
219
+ next_token: Token for pagination (optional, for retrieving next page)
220
+
221
+ Returns:
222
+ VendorAssistantAliasesResponse containing list of aliases and pagination token
223
+
224
+ Example:
225
+ >>> # Get first page of aliases
226
+ >>> aliases = client.vendor_assistants.get_assistant_aliases(
227
+ ... vendor=VendorType.AWS,
228
+ ... assistant_id="TJBKR0DGWT",
229
+ ... setting_id="cac90788-39b7-4ffe-8b57-e8b047fa1f6c",
230
+ ... per_page=5
231
+ ... )
232
+ >>> for alias in aliases.data:
233
+ ... print(f"{alias.name} (v{alias.version}): {alias.status}")
234
+ >>> # Get next page if available
235
+ >>> if aliases.pagination.next_token:
236
+ ... next_page = client.vendor_assistants.get_assistant_aliases(
237
+ ... vendor=VendorType.AWS,
238
+ ... assistant_id="TJBKR0DGWT",
239
+ ... setting_id="cac90788-39b7-4ffe-8b57-e8b047fa1f6c",
240
+ ... per_page=5,
241
+ ... next_token=aliases.pagination.next_token
242
+ ... )
243
+ """
244
+ # Convert enum to string value if needed
245
+ vendor_str = vendor.value if isinstance(vendor, VendorType) else vendor
246
+
247
+ params = {
248
+ "setting_id": setting_id,
249
+ "per_page": per_page,
250
+ }
251
+
252
+ if next_token:
253
+ params["next_token"] = next_token
254
+
255
+ return self._api.get(
256
+ f"/v1/vendors/{vendor_str}/assistants/{assistant_id}/aliases",
257
+ VendorAssistantAliasesResponse,
258
+ params=params,
259
+ wrap_response=False,
260
+ )
261
+
262
+ def install_assistants(
263
+ self,
264
+ vendor: Union[VendorType, str],
265
+ assistants: List[VendorAssistantInstallRequest],
266
+ ) -> VendorAssistantInstallResponse:
267
+ """Install/activate vendor assistants.
268
+
269
+ Args:
270
+ vendor: Cloud vendor type (aws, azure, gcp). Can be VendorType enum or string.
271
+ assistants: List of assistant installation requests with assistant ID, alias ID, and setting ID
272
+
273
+ Returns:
274
+ VendorAssistantInstallResponse containing installation summary with AI run IDs
275
+
276
+ Example:
277
+ >>> from codemie_sdk import VendorAssistantInstallRequest
278
+ >>> # Install single assistant
279
+ >>> install_request = VendorAssistantInstallRequest(
280
+ ... id="TJBKR0DGWT",
281
+ ... agentAliasId="MNULODIW4N",
282
+ ... setting_id="cac90788-39b7-4ffe-8b57-e8b047fa1f6c"
283
+ ... )
284
+ >>> response = client.vendor_assistants.install_assistants(
285
+ ... vendor=VendorType.AWS,
286
+ ... assistants=[install_request]
287
+ ... )
288
+ >>> for item in response.summary:
289
+ ... print(f"Installed {item.agentId} with run ID: {item.aiRunId}")
290
+ >>>
291
+ >>> # Install multiple assistants
292
+ >>> requests = [
293
+ ... VendorAssistantInstallRequest(
294
+ ... id="ASSISTANT_ID_1",
295
+ ... agentAliasId="ALIAS_ID_1",
296
+ ... setting_id="SETTING_ID"
297
+ ... ),
298
+ ... VendorAssistantInstallRequest(
299
+ ... id="ASSISTANT_ID_2",
300
+ ... agentAliasId="ALIAS_ID_2",
301
+ ... setting_id="SETTING_ID"
302
+ ... )
303
+ ... ]
304
+ >>> response = client.vendor_assistants.install_assistants(
305
+ ... vendor=VendorType.AWS,
306
+ ... assistants=requests
307
+ ... )
308
+ """
309
+ # Convert enum to string value if needed
310
+ vendor_str = vendor.value if isinstance(vendor, VendorType) else vendor
311
+
312
+ # Convert list of Pydantic models to list of dicts
313
+ payload = [assistant.model_dump(by_alias=True) for assistant in assistants]
314
+
315
+ return self._api.post(
316
+ f"/v1/vendors/{vendor_str}/assistants",
317
+ VendorAssistantInstallResponse,
318
+ json_data=payload,
319
+ wrap_response=False,
320
+ )
321
+
322
+ def uninstall_assistant(
323
+ self,
324
+ vendor: Union[VendorType, str],
325
+ ai_run_id: str,
326
+ ) -> VendorAssistantUninstallResponse:
327
+ """Uninstall/deactivate a vendor assistant.
328
+
329
+ Args:
330
+ vendor: Cloud vendor type (aws, azure, gcp). Can be VendorType enum or string.
331
+ ai_run_id: AI run ID returned from the install operation
332
+
333
+ Returns:
334
+ VendorAssistantUninstallResponse with success status
335
+
336
+ Example:
337
+ >>> # First, install an assistant
338
+ >>> install_request = VendorAssistantInstallRequest(
339
+ ... id="TJBKR0DGWT",
340
+ ... agentAliasId="MNULODIW4N",
341
+ ... setting_id="cac90788-39b7-4ffe-8b57-e8b047fa1f6c"
342
+ ... )
343
+ >>> install_response = client.vendor_assistants.install_assistants(
344
+ ... vendor=VendorType.AWS,
345
+ ... assistants=[install_request]
346
+ ... )
347
+ >>> ai_run_id = install_response.summary[0].aiRunId
348
+ >>>
349
+ >>> # Later, uninstall the assistant using the AI run ID
350
+ >>> response = client.vendor_assistants.uninstall_assistant(
351
+ ... vendor=VendorType.AWS,
352
+ ... ai_run_id=ai_run_id
353
+ ... )
354
+ >>> if response.success:
355
+ ... print("Assistant successfully uninstalled!")
356
+ """
357
+ # Convert enum to string value if needed
358
+ vendor_str = vendor.value if isinstance(vendor, VendorType) else vendor
359
+
360
+ return self._api.delete(
361
+ f"/v1/vendors/{vendor_str}/assistants/{ai_run_id}",
362
+ VendorAssistantUninstallResponse,
363
+ wrap_response=False,
364
+ )