datarobot-genai 0.2.34__py3-none-any.whl → 0.2.39__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.
- datarobot_genai/drmcp/tools/clients/microsoft_graph.py +171 -0
- datarobot_genai/drmcp/tools/confluence/tools.py +43 -89
- datarobot_genai/drmcp/tools/gdrive/tools.py +32 -74
- datarobot_genai/drmcp/tools/jira/tools.py +15 -33
- datarobot_genai/drmcp/tools/microsoft_graph/tools.py +152 -20
- datarobot_genai/drmcp/tools/predictive/deployment.py +52 -46
- datarobot_genai/drmcp/tools/predictive/deployment_info.py +100 -107
- datarobot_genai/drmcp/tools/predictive/training.py +38 -10
- {datarobot_genai-0.2.34.dist-info → datarobot_genai-0.2.39.dist-info}/METADATA +1 -1
- {datarobot_genai-0.2.34.dist-info → datarobot_genai-0.2.39.dist-info}/RECORD +14 -14
- {datarobot_genai-0.2.34.dist-info → datarobot_genai-0.2.39.dist-info}/WHEEL +0 -0
- {datarobot_genai-0.2.34.dist-info → datarobot_genai-0.2.39.dist-info}/entry_points.txt +0 -0
- {datarobot_genai-0.2.34.dist-info → datarobot_genai-0.2.39.dist-info}/licenses/AUTHORS +0 -0
- {datarobot_genai-0.2.34.dist-info → datarobot_genai-0.2.39.dist-info}/licenses/LICENSE +0 -0
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
import logging
|
|
18
18
|
from typing import Any
|
|
19
|
+
from typing import Literal
|
|
20
|
+
from urllib.parse import quote
|
|
19
21
|
|
|
20
22
|
import httpx
|
|
21
23
|
from datarobot.auth.datarobot.exceptions import OAuthServiceClientErr
|
|
@@ -415,6 +417,175 @@ class MicrosoftGraphClient:
|
|
|
415
417
|
|
|
416
418
|
return base_resource
|
|
417
419
|
|
|
420
|
+
async def get_personal_drive_id(self) -> str:
|
|
421
|
+
"""Get the current user's personal OneDrive drive ID.
|
|
422
|
+
|
|
423
|
+
Returns
|
|
424
|
+
-------
|
|
425
|
+
The drive ID string for the user's personal OneDrive.
|
|
426
|
+
|
|
427
|
+
Raises
|
|
428
|
+
------
|
|
429
|
+
MicrosoftGraphError: If the drive cannot be retrieved.
|
|
430
|
+
"""
|
|
431
|
+
try:
|
|
432
|
+
response = await self._client.get(f"{GRAPH_API_BASE}/me/drive")
|
|
433
|
+
response.raise_for_status()
|
|
434
|
+
data = response.json()
|
|
435
|
+
return data["id"]
|
|
436
|
+
except httpx.HTTPStatusError as e:
|
|
437
|
+
status_code = e.response.status_code
|
|
438
|
+
if status_code == 401:
|
|
439
|
+
raise MicrosoftGraphError(
|
|
440
|
+
"Authentication failed. Access token may be expired or invalid."
|
|
441
|
+
) from e
|
|
442
|
+
if status_code == 403:
|
|
443
|
+
raise MicrosoftGraphError(
|
|
444
|
+
"Permission denied: cannot access personal OneDrive. "
|
|
445
|
+
"Requires Files.Read or Files.ReadWrite permission."
|
|
446
|
+
) from e
|
|
447
|
+
raise MicrosoftGraphError(f"Failed to get personal OneDrive: HTTP {status_code}") from e
|
|
448
|
+
|
|
449
|
+
async def create_file(
|
|
450
|
+
self,
|
|
451
|
+
drive_id: str,
|
|
452
|
+
file_name: str,
|
|
453
|
+
content: str,
|
|
454
|
+
parent_folder_id: str = "root",
|
|
455
|
+
conflict_behavior: str = "rename",
|
|
456
|
+
) -> MicrosoftGraphItem:
|
|
457
|
+
"""Create a text file in a drive (SharePoint document library or OneDrive).
|
|
458
|
+
|
|
459
|
+
Uses Microsoft Graph's simple upload endpoint for files < 4MB.
|
|
460
|
+
Files are created as text/plain content.
|
|
461
|
+
|
|
462
|
+
Args:
|
|
463
|
+
drive_id: The ID of the drive (document library) where the file will be created.
|
|
464
|
+
file_name: The name of the file to create (e.g., 'report.txt').
|
|
465
|
+
content: The text content to store in the file.
|
|
466
|
+
parent_folder_id: ID of the parent folder. Defaults to "root" (drive root folder).
|
|
467
|
+
conflict_behavior: How to handle name conflicts. Options:
|
|
468
|
+
- "rename" (default): Auto-renames to 'filename (1).txt', etc.
|
|
469
|
+
- "fail": Returns 409 Conflict error
|
|
470
|
+
- "replace": Overwrites existing file
|
|
471
|
+
|
|
472
|
+
Returns
|
|
473
|
+
-------
|
|
474
|
+
MicrosoftGraphItem representing the created file.
|
|
475
|
+
|
|
476
|
+
Raises
|
|
477
|
+
------
|
|
478
|
+
MicrosoftGraphError: If file creation fails.
|
|
479
|
+
"""
|
|
480
|
+
if not drive_id or not drive_id.strip():
|
|
481
|
+
raise MicrosoftGraphError("drive_id cannot be empty")
|
|
482
|
+
if not file_name or not file_name.strip():
|
|
483
|
+
raise MicrosoftGraphError("file_name cannot be empty")
|
|
484
|
+
|
|
485
|
+
# URL encode the filename for path-based addressing
|
|
486
|
+
encoded_name = quote(file_name, safe="")
|
|
487
|
+
|
|
488
|
+
# Simple upload endpoint for files < 4MB
|
|
489
|
+
# Reference: https://learn.microsoft.com/en-us/graph/api/driveitem-put-content
|
|
490
|
+
upload_url = (
|
|
491
|
+
f"{GRAPH_API_BASE}/drives/{drive_id}/items/{parent_folder_id}:/{encoded_name}:/content"
|
|
492
|
+
)
|
|
493
|
+
|
|
494
|
+
try:
|
|
495
|
+
response = await self._client.put(
|
|
496
|
+
upload_url,
|
|
497
|
+
content=content.encode("utf-8"),
|
|
498
|
+
headers={"Content-Type": "text/plain"},
|
|
499
|
+
params={"@microsoft.graph.conflictBehavior": conflict_behavior},
|
|
500
|
+
)
|
|
501
|
+
response.raise_for_status()
|
|
502
|
+
except httpx.HTTPStatusError as e:
|
|
503
|
+
raise self._handle_create_file_error(e, drive_id, file_name, parent_folder_id) from e
|
|
504
|
+
|
|
505
|
+
return MicrosoftGraphItem.from_api_response(response.json())
|
|
506
|
+
|
|
507
|
+
def _handle_create_file_error(
|
|
508
|
+
self,
|
|
509
|
+
error: httpx.HTTPStatusError,
|
|
510
|
+
drive_id: str,
|
|
511
|
+
file_name: str,
|
|
512
|
+
parent_folder_id: str,
|
|
513
|
+
) -> MicrosoftGraphError:
|
|
514
|
+
"""Handle HTTP errors for file creation and return appropriate MicrosoftGraphError."""
|
|
515
|
+
status_code = error.response.status_code
|
|
516
|
+
error_msg = f"Failed to create file: HTTP {status_code}"
|
|
517
|
+
|
|
518
|
+
if status_code == 400:
|
|
519
|
+
try:
|
|
520
|
+
error_data = error.response.json()
|
|
521
|
+
api_message = error_data.get("error", {}).get("message", "Invalid request")
|
|
522
|
+
error_msg = f"Bad request creating file: {api_message}"
|
|
523
|
+
except Exception:
|
|
524
|
+
error_msg = "Bad request: invalid parameters for file creation."
|
|
525
|
+
elif status_code == 401:
|
|
526
|
+
error_msg = "Authentication failed. Access token may be expired or invalid."
|
|
527
|
+
elif status_code == 403:
|
|
528
|
+
error_msg = (
|
|
529
|
+
f"Permission denied: you don't have permission to create files in drive "
|
|
530
|
+
f"'{drive_id}'. Requires Files.ReadWrite.All permission."
|
|
531
|
+
)
|
|
532
|
+
elif status_code == 404:
|
|
533
|
+
error_msg = (
|
|
534
|
+
f"Parent folder '{parent_folder_id}' not found in drive '{drive_id}'."
|
|
535
|
+
if parent_folder_id != "root"
|
|
536
|
+
else f"Drive '{drive_id}' not found."
|
|
537
|
+
)
|
|
538
|
+
elif status_code == 409:
|
|
539
|
+
error_msg = f"File '{file_name}' already exists and conflict behavior is set to 'fail'."
|
|
540
|
+
elif status_code == 429:
|
|
541
|
+
error_msg = "Rate limit exceeded. Please try again later."
|
|
542
|
+
|
|
543
|
+
return MicrosoftGraphError(error_msg)
|
|
544
|
+
|
|
545
|
+
async def share_item(
|
|
546
|
+
self,
|
|
547
|
+
file_id: str,
|
|
548
|
+
document_library_id: str,
|
|
549
|
+
recipient_emails: list[str],
|
|
550
|
+
role: Literal["read", "write"],
|
|
551
|
+
send_invitation: bool,
|
|
552
|
+
) -> None:
|
|
553
|
+
"""
|
|
554
|
+
Share sharepoint / ondrive item using Microsoft Graph API.
|
|
555
|
+
Under the hood all resources in sharepoint/onedrive
|
|
556
|
+
in MS Graph API are treated as 'driveItem'.
|
|
557
|
+
|
|
558
|
+
Args:
|
|
559
|
+
file_id: The ID of the file or folder to share.
|
|
560
|
+
document_library_id: The ID of the document library containing the item.
|
|
561
|
+
recipient_emails: A list of email addresses to invite.
|
|
562
|
+
role: The role to assign.
|
|
563
|
+
send_invitation: Flag determining if recipients should be notified
|
|
564
|
+
|
|
565
|
+
Returns
|
|
566
|
+
-------
|
|
567
|
+
None
|
|
568
|
+
|
|
569
|
+
Raises
|
|
570
|
+
------
|
|
571
|
+
MicrosoftGraphError: If sharing fails
|
|
572
|
+
"""
|
|
573
|
+
graph_url = f"{GRAPH_API_BASE}/drives/{document_library_id}/items/{file_id}/invite"
|
|
574
|
+
|
|
575
|
+
payload = {
|
|
576
|
+
"recipients": [{"email": email} for email in recipient_emails],
|
|
577
|
+
"requireSignIn": True,
|
|
578
|
+
"sendInvitation": send_invitation,
|
|
579
|
+
"roles": [role],
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
response = await self._client.post(url=graph_url, json=payload)
|
|
583
|
+
|
|
584
|
+
if response.status_code not in (200, 201):
|
|
585
|
+
raise MicrosoftGraphError(
|
|
586
|
+
f"Microsoft Graph API error {response.status_code}: {response.text}"
|
|
587
|
+
)
|
|
588
|
+
|
|
418
589
|
async def __aenter__(self) -> "MicrosoftGraphClient":
|
|
419
590
|
"""Async context manager entry."""
|
|
420
591
|
return self
|
|
@@ -55,26 +55,16 @@ async def confluence_get_page(
|
|
|
55
55
|
if isinstance(access_token, ToolError):
|
|
56
56
|
raise access_token
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
page_response = await client.get_page_by_title(page_id_or_title, space_key)
|
|
69
|
-
except ConfluenceError as e:
|
|
70
|
-
logger.error(f"Confluence error getting page: {e}")
|
|
71
|
-
raise ToolError(str(e))
|
|
72
|
-
except Exception as e:
|
|
73
|
-
logger.error(f"Unexpected error getting Confluence page: {e}")
|
|
74
|
-
raise ToolError(
|
|
75
|
-
f"An unexpected error occurred while getting Confluence page "
|
|
76
|
-
f"'{page_id_or_title}': {str(e)}"
|
|
77
|
-
)
|
|
58
|
+
async with ConfluenceClient(access_token) as client:
|
|
59
|
+
if page_id_or_title.isdigit():
|
|
60
|
+
page_response = await client.get_page_by_id(page_id_or_title)
|
|
61
|
+
else:
|
|
62
|
+
if not space_key:
|
|
63
|
+
raise ToolError(
|
|
64
|
+
"Argument validation error: "
|
|
65
|
+
"'space_key' is required when identifying a page by title."
|
|
66
|
+
)
|
|
67
|
+
page_response = await client.get_page_by_title(page_id_or_title, space_key)
|
|
78
68
|
|
|
79
69
|
return ToolResult(
|
|
80
70
|
content=f"Successfully retrieved page '{page_response.title}'.",
|
|
@@ -116,22 +106,12 @@ async def confluence_create_page(
|
|
|
116
106
|
if isinstance(access_token, ToolError):
|
|
117
107
|
raise access_token
|
|
118
108
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
parent_id=parent_id,
|
|
126
|
-
)
|
|
127
|
-
except ConfluenceError as e:
|
|
128
|
-
logger.error(f"Confluence error creating page: {e}")
|
|
129
|
-
raise ToolError(str(e))
|
|
130
|
-
except Exception as e:
|
|
131
|
-
logger.error(f"Unexpected error creating Confluence page: {e}")
|
|
132
|
-
raise ToolError(
|
|
133
|
-
f"An unexpected error occurred while creating Confluence page "
|
|
134
|
-
f"'{title}' in space '{space_key}': {str(e)}"
|
|
109
|
+
async with ConfluenceClient(access_token) as client:
|
|
110
|
+
page_response = await client.create_page(
|
|
111
|
+
space_key=space_key,
|
|
112
|
+
title=title,
|
|
113
|
+
body_content=body_content,
|
|
114
|
+
parent_id=parent_id,
|
|
135
115
|
)
|
|
136
116
|
|
|
137
117
|
return ToolResult(
|
|
@@ -164,19 +144,10 @@ async def confluence_add_comment(
|
|
|
164
144
|
if isinstance(access_token, ToolError):
|
|
165
145
|
raise access_token
|
|
166
146
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
comment_body=comment_body,
|
|
172
|
-
)
|
|
173
|
-
except ConfluenceError as e:
|
|
174
|
-
logger.error(f"Confluence error adding comment: {e}")
|
|
175
|
-
raise ToolError(str(e))
|
|
176
|
-
except Exception as e:
|
|
177
|
-
logger.error(f"Unexpected error adding comment to Confluence page: {e}")
|
|
178
|
-
raise ToolError(
|
|
179
|
-
f"An unexpected error occurred while adding comment to page '{page_id}': {str(e)}"
|
|
147
|
+
async with ConfluenceClient(access_token) as client:
|
|
148
|
+
comment_response = await client.add_comment(
|
|
149
|
+
page_id=page_id,
|
|
150
|
+
comment_body=comment_body,
|
|
180
151
|
)
|
|
181
152
|
|
|
182
153
|
return ToolResult(
|
|
@@ -220,32 +191,24 @@ async def confluence_search(
|
|
|
220
191
|
if isinstance(access_token, ToolError):
|
|
221
192
|
raise access_token
|
|
222
193
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
data = [result.as_flat_dict() for result in results]
|
|
242
|
-
|
|
243
|
-
except ConfluenceError as e:
|
|
244
|
-
logger.error(f"Confluence error searching content: {e}")
|
|
245
|
-
raise ToolError(str(e))
|
|
246
|
-
except Exception as e:
|
|
247
|
-
logger.error(f"Unexpected error searching Confluence content: {e}")
|
|
248
|
-
raise ToolError(f"An unexpected error occurred while searching Confluence: {str(e)}")
|
|
194
|
+
async with ConfluenceClient(access_token) as client:
|
|
195
|
+
results = await client.search_confluence_content(
|
|
196
|
+
cql_query=cql_query, max_results=max_results
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
# If include_body is True, fetch full content for each page
|
|
200
|
+
if include_body and results:
|
|
201
|
+
data = []
|
|
202
|
+
for result in results:
|
|
203
|
+
flat = result.as_flat_dict()
|
|
204
|
+
try:
|
|
205
|
+
page = await client.get_page_by_id(result.id)
|
|
206
|
+
flat["body"] = page.body
|
|
207
|
+
except ConfluenceError:
|
|
208
|
+
flat["body"] = None # Keep excerpt if page fetch fails
|
|
209
|
+
data.append(flat)
|
|
210
|
+
else:
|
|
211
|
+
data = [result.as_flat_dict() for result in results]
|
|
249
212
|
|
|
250
213
|
n = len(results)
|
|
251
214
|
return ToolResult(
|
|
@@ -296,20 +259,11 @@ async def confluence_update_page(
|
|
|
296
259
|
if isinstance(access_token, ToolError):
|
|
297
260
|
raise access_token
|
|
298
261
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
version_number=version_number,
|
|
305
|
-
)
|
|
306
|
-
except ConfluenceError as e:
|
|
307
|
-
logger.error(f"Confluence error updating page: {e}")
|
|
308
|
-
raise ToolError(str(e))
|
|
309
|
-
except Exception as e:
|
|
310
|
-
logger.error(f"Unexpected error updating Confluence page: {e}")
|
|
311
|
-
raise ToolError(
|
|
312
|
-
f"An unexpected error occurred while updating Confluence page '{page_id}': {str(e)}"
|
|
262
|
+
async with ConfluenceClient(access_token) as client:
|
|
263
|
+
page_response = await client.update_page(
|
|
264
|
+
page_id=page_id,
|
|
265
|
+
new_body_content=new_body_content,
|
|
266
|
+
version_number=version_number,
|
|
313
267
|
)
|
|
314
268
|
|
|
315
269
|
return ToolResult(
|
|
@@ -28,7 +28,6 @@ from datarobot_genai.drmcp.tools.clients.gdrive import MAX_PAGE_SIZE
|
|
|
28
28
|
from datarobot_genai.drmcp.tools.clients.gdrive import SUPPORTED_FIELDS
|
|
29
29
|
from datarobot_genai.drmcp.tools.clients.gdrive import SUPPORTED_FIELDS_STR
|
|
30
30
|
from datarobot_genai.drmcp.tools.clients.gdrive import GoogleDriveClient
|
|
31
|
-
from datarobot_genai.drmcp.tools.clients.gdrive import GoogleDriveError
|
|
32
31
|
from datarobot_genai.drmcp.tools.clients.gdrive import get_gdrive_access_token
|
|
33
32
|
|
|
34
33
|
logger = logging.getLogger(__name__)
|
|
@@ -79,22 +78,15 @@ async def gdrive_find_contents(
|
|
|
79
78
|
if isinstance(access_token, ToolError):
|
|
80
79
|
raise access_token
|
|
81
80
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
)
|
|
92
|
-
except GoogleDriveError as e:
|
|
93
|
-
logger.error(f"Google Drive error listing files: {e}")
|
|
94
|
-
raise ToolError(str(e))
|
|
95
|
-
except Exception as e:
|
|
96
|
-
logger.error(f"Unexpected error listing Google Drive files: {e}")
|
|
97
|
-
raise ToolError(f"An unexpected error occurred while listing Google Drive files: {str(e)}")
|
|
81
|
+
async with GoogleDriveClient(access_token) as client:
|
|
82
|
+
data = await client.list_files(
|
|
83
|
+
page_size=page_size,
|
|
84
|
+
page_token=page_token,
|
|
85
|
+
query=query,
|
|
86
|
+
limit=limit,
|
|
87
|
+
folder_id=folder_id,
|
|
88
|
+
recursive=recursive,
|
|
89
|
+
)
|
|
98
90
|
|
|
99
91
|
filtered_fields = set(fields).intersection(SUPPORTED_FIELDS) if fields else SUPPORTED_FIELDS
|
|
100
92
|
number_of_files = len(data.files)
|
|
@@ -155,17 +147,8 @@ async def gdrive_read_content(
|
|
|
155
147
|
if isinstance(access_token, ToolError):
|
|
156
148
|
raise access_token
|
|
157
149
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
file_content = await client.read_file_content(file_id, target_format)
|
|
161
|
-
except GoogleDriveError as e:
|
|
162
|
-
logger.error(f"Google Drive error reading file content: {e}")
|
|
163
|
-
raise ToolError(str(e))
|
|
164
|
-
except Exception as e:
|
|
165
|
-
logger.error(f"Unexpected error reading Google Drive file content: {e}")
|
|
166
|
-
raise ToolError(
|
|
167
|
-
f"An unexpected error occurred while reading Google Drive file content: {str(e)}"
|
|
168
|
-
)
|
|
150
|
+
async with GoogleDriveClient(access_token) as client:
|
|
151
|
+
file_content = await client.read_file_content(file_id, target_format)
|
|
169
152
|
|
|
170
153
|
export_info = ""
|
|
171
154
|
if file_content.was_exported:
|
|
@@ -239,20 +222,13 @@ async def gdrive_create_file(
|
|
|
239
222
|
if isinstance(access_token, ToolError):
|
|
240
223
|
raise access_token
|
|
241
224
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
)
|
|
250
|
-
except GoogleDriveError as e:
|
|
251
|
-
logger.error(f"Google Drive error creating file: {e}")
|
|
252
|
-
raise ToolError(str(e))
|
|
253
|
-
except Exception as e:
|
|
254
|
-
logger.error(f"Unexpected error creating Google Drive file: {e}")
|
|
255
|
-
raise ToolError(f"An unexpected error occurred while creating Google Drive file: {str(e)}")
|
|
225
|
+
async with GoogleDriveClient(access_token) as client:
|
|
226
|
+
created_file = await client.create_file(
|
|
227
|
+
name=name,
|
|
228
|
+
mime_type=mime_type,
|
|
229
|
+
parent_id=parent_id,
|
|
230
|
+
initial_content=initial_content,
|
|
231
|
+
)
|
|
256
232
|
|
|
257
233
|
file_type = "folder" if mime_type == GOOGLE_DRIVE_FOLDER_MIME else "file"
|
|
258
234
|
content_info = ""
|
|
@@ -313,21 +289,12 @@ async def gdrive_update_metadata(
|
|
|
313
289
|
if isinstance(access_token, ToolError):
|
|
314
290
|
raise access_token
|
|
315
291
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
trashed=trash,
|
|
323
|
-
)
|
|
324
|
-
except GoogleDriveError as e:
|
|
325
|
-
logger.error(f"Google Drive error updating file metadata: {e}")
|
|
326
|
-
raise ToolError(str(e))
|
|
327
|
-
except Exception as e:
|
|
328
|
-
logger.error(f"Unexpected error updating Google Drive file metadata: {e}")
|
|
329
|
-
raise ToolError(
|
|
330
|
-
f"An unexpected error occurred while updating Google Drive file metadata: {str(e)}"
|
|
292
|
+
async with GoogleDriveClient(access_token) as client:
|
|
293
|
+
updated_file = await client.update_file_metadata(
|
|
294
|
+
file_id=file_id,
|
|
295
|
+
new_name=new_name,
|
|
296
|
+
starred=starred,
|
|
297
|
+
trashed=trash,
|
|
331
298
|
)
|
|
332
299
|
|
|
333
300
|
changes: list[str] = []
|
|
@@ -408,23 +375,14 @@ async def gdrive_manage_access(
|
|
|
408
375
|
if isinstance(access_token, ToolError):
|
|
409
376
|
raise access_token
|
|
410
377
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
transfer_ownership=transfer_ownership,
|
|
420
|
-
)
|
|
421
|
-
except GoogleDriveError as e:
|
|
422
|
-
logger.error(f"Google Drive permission operation failed: {e}")
|
|
423
|
-
raise ToolError(str(e))
|
|
424
|
-
except Exception as e:
|
|
425
|
-
logger.error(f"Unexpected error changing permissions for Google Drive file {file_id}: {e}")
|
|
426
|
-
raise ToolError(
|
|
427
|
-
f"Unexpected error changing permissions for Google Drive file {file_id}: {str(e)}"
|
|
378
|
+
async with GoogleDriveClient(access_token) as client:
|
|
379
|
+
permission_id = await client.manage_access(
|
|
380
|
+
file_id=file_id,
|
|
381
|
+
action=action,
|
|
382
|
+
role=role,
|
|
383
|
+
email_address=email_address,
|
|
384
|
+
permission_id=permission_id,
|
|
385
|
+
transfer_ownership=transfer_ownership,
|
|
428
386
|
)
|
|
429
387
|
|
|
430
388
|
# Build response
|
|
@@ -72,14 +72,8 @@ async def jira_get_issue(
|
|
|
72
72
|
if isinstance(access_token, ToolError):
|
|
73
73
|
raise access_token
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
issue = await client.get_jira_issue(issue_key)
|
|
78
|
-
except Exception as e:
|
|
79
|
-
logger.error(f"Unexpected error while getting Jira issue: {e}")
|
|
80
|
-
raise ToolError(
|
|
81
|
-
f"An unexpected error occurred while getting Jira issue '{issue_key}': {str(e)}"
|
|
82
|
-
)
|
|
75
|
+
async with JiraClient(access_token) as client:
|
|
76
|
+
issue = await client.get_jira_issue(issue_key)
|
|
83
77
|
|
|
84
78
|
return ToolResult(
|
|
85
79
|
content=f"Successfully retrieved details for issue '{issue_key}'.",
|
|
@@ -118,17 +112,13 @@ async def jira_create_issue(
|
|
|
118
112
|
f"Unexpected issue type `{issue_type}`. Possible values are {possible_issue_types}."
|
|
119
113
|
)
|
|
120
114
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
)
|
|
129
|
-
except Exception as e:
|
|
130
|
-
logger.error(f"Unexpected error while creating Jira issue: {e}")
|
|
131
|
-
raise ToolError(f"An unexpected error occurred while creating Jira issue: {str(e)}")
|
|
115
|
+
async with JiraClient(access_token) as client:
|
|
116
|
+
issue_key = await client.create_jira_issue(
|
|
117
|
+
project_key=project_key,
|
|
118
|
+
summary=summary,
|
|
119
|
+
issue_type_id=issue_type_id,
|
|
120
|
+
description=description,
|
|
121
|
+
)
|
|
132
122
|
|
|
133
123
|
return ToolResult(
|
|
134
124
|
content=f"Successfully created issue '{issue_key}'.",
|
|
@@ -179,14 +169,10 @@ async def jira_update_issue(
|
|
|
179
169
|
if isinstance(access_token, ToolError):
|
|
180
170
|
raise access_token
|
|
181
171
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
)
|
|
187
|
-
except Exception as e:
|
|
188
|
-
logger.error(f"Unexpected error while updating Jira issue: {e}")
|
|
189
|
-
raise ToolError(f"An unexpected error occurred while updating Jira issue: {str(e)}")
|
|
172
|
+
async with JiraClient(access_token) as client:
|
|
173
|
+
updated_fields = await client.update_jira_issue(
|
|
174
|
+
issue_key=issue_key, fields=fields_to_update
|
|
175
|
+
)
|
|
190
176
|
|
|
191
177
|
updated_fields_str = ",".join(updated_fields)
|
|
192
178
|
return ToolResult(
|
|
@@ -226,12 +212,8 @@ async def jira_transition_issue(
|
|
|
226
212
|
f"Possible values are {available_transitions_str}."
|
|
227
213
|
)
|
|
228
214
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
await client.transition_jira_issue(issue_key=issue_key, transition_id=transition_id)
|
|
232
|
-
except Exception as e:
|
|
233
|
-
logger.error(f"Unexpected error while transitioning Jira issue: {e}")
|
|
234
|
-
raise ToolError(f"An unexpected error occurred while transitioning Jira issue: {str(e)}")
|
|
215
|
+
async with JiraClient(access_token) as client:
|
|
216
|
+
await client.transition_jira_issue(issue_key=issue_key, transition_id=transition_id)
|
|
235
217
|
|
|
236
218
|
return ToolResult(
|
|
237
219
|
content=f"Successfully transitioned issue '{issue_key}' to status '{transition_name}'.",
|