datarobot-genai 0.2.13__py3-none-any.whl → 0.2.20__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.
Files changed (26) hide show
  1. datarobot_genai/drmcp/core/config.py +24 -0
  2. datarobot_genai/drmcp/core/tool_config.py +8 -0
  3. datarobot_genai/drmcp/core/utils.py +7 -0
  4. datarobot_genai/drmcp/test_utils/elicitation_test_tool.py +89 -0
  5. datarobot_genai/drmcp/test_utils/integration_mcp_server.py +7 -0
  6. datarobot_genai/drmcp/test_utils/mcp_utils_ete.py +9 -1
  7. datarobot_genai/drmcp/test_utils/mcp_utils_integration.py +17 -4
  8. datarobot_genai/drmcp/test_utils/openai_llm_mcp_client.py +71 -8
  9. datarobot_genai/drmcp/test_utils/test_interactive.py +205 -0
  10. datarobot_genai/drmcp/test_utils/tool_base_ete.py +22 -20
  11. datarobot_genai/drmcp/tools/clients/confluence.py +201 -4
  12. datarobot_genai/drmcp/tools/clients/gdrive.py +248 -0
  13. datarobot_genai/drmcp/tools/clients/jira.py +119 -5
  14. datarobot_genai/drmcp/tools/confluence/tools.py +109 -2
  15. datarobot_genai/drmcp/tools/gdrive/__init__.py +0 -0
  16. datarobot_genai/drmcp/tools/gdrive/tools.py +88 -0
  17. datarobot_genai/drmcp/tools/jira/tools.py +142 -0
  18. datarobot_genai/drmcp/tools/predictive/data.py +60 -32
  19. datarobot_genai/nat/agent.py +20 -7
  20. datarobot_genai/nat/helpers.py +87 -0
  21. {datarobot_genai-0.2.13.dist-info → datarobot_genai-0.2.20.dist-info}/METADATA +1 -1
  22. {datarobot_genai-0.2.13.dist-info → datarobot_genai-0.2.20.dist-info}/RECORD +26 -20
  23. {datarobot_genai-0.2.13.dist-info → datarobot_genai-0.2.20.dist-info}/WHEEL +0 -0
  24. {datarobot_genai-0.2.13.dist-info → datarobot_genai-0.2.20.dist-info}/entry_points.txt +0 -0
  25. {datarobot_genai-0.2.13.dist-info → datarobot_genai-0.2.20.dist-info}/licenses/AUTHORS +0 -0
  26. {datarobot_genai-0.2.13.dist-info → datarobot_genai-0.2.20.dist-info}/licenses/LICENSE +0 -0
@@ -31,6 +31,14 @@ from .atlassian import get_atlassian_cloud_id
31
31
  logger = logging.getLogger(__name__)
32
32
 
33
33
 
34
+ class ConfluenceError(Exception):
35
+ """Exception for Confluence API errors."""
36
+
37
+ def __init__(self, message: str, status_code: int | None = None) -> None:
38
+ super().__init__(message)
39
+ self.status_code = status_code
40
+
41
+
34
42
  class ConfluencePage(BaseModel):
35
43
  """Pydantic model for Confluence page."""
36
44
 
@@ -51,6 +59,22 @@ class ConfluencePage(BaseModel):
51
59
  }
52
60
 
53
61
 
62
+ class ConfluenceComment(BaseModel):
63
+ """Pydantic model for Confluence comment."""
64
+
65
+ comment_id: str = Field(..., description="The unique comment ID")
66
+ page_id: str = Field(..., description="The page ID where the comment was added")
67
+ body: str = Field(..., description="Comment content in storage format")
68
+
69
+ def as_flat_dict(self) -> dict[str, Any]:
70
+ """Return a flat dictionary representation of the comment."""
71
+ return {
72
+ "comment_id": self.comment_id,
73
+ "page_id": self.page_id,
74
+ "body": self.body,
75
+ }
76
+
77
+
54
78
  class ConfluenceClient:
55
79
  """
56
80
  Client for interacting with Confluence API using OAuth access token.
@@ -133,7 +157,7 @@ class ConfluenceClient:
133
157
 
134
158
  Raises
135
159
  ------
136
- ValueError: If page is not found
160
+ ConfluenceError: If page is not found
137
161
  httpx.HTTPStatusError: If the API request fails
138
162
  """
139
163
  cloud_id = await self._get_cloud_id()
@@ -142,7 +166,7 @@ class ConfluenceClient:
142
166
  response = await self._client.get(url, params={"expand": self.EXPAND_FIELDS})
143
167
 
144
168
  if response.status_code == HTTPStatus.NOT_FOUND:
145
- raise ValueError(f"Page with ID '{page_id}' not found")
169
+ raise ConfluenceError(f"Page with ID '{page_id}' not found", status_code=404)
146
170
 
147
171
  response.raise_for_status()
148
172
  return self._parse_response(response.json())
@@ -161,7 +185,7 @@ class ConfluenceClient:
161
185
 
162
186
  Raises
163
187
  ------
164
- ValueError: If the page is not found
188
+ ConfluenceError: If the page is not found
165
189
  httpx.HTTPStatusError: If the API request fails
166
190
  """
167
191
  cloud_id = await self._get_cloud_id()
@@ -181,10 +205,183 @@ class ConfluenceClient:
181
205
  results = data.get("results", [])
182
206
 
183
207
  if not results:
184
- raise ValueError(f"Page with title '{title}' not found in space '{space_key}'")
208
+ raise ConfluenceError(
209
+ f"Page with title '{title}' not found in space '{space_key}'", status_code=404
210
+ )
185
211
 
186
212
  return self._parse_response(results[0])
187
213
 
214
+ def _extract_error_message(self, response: httpx.Response) -> str:
215
+ """Extract error message from Confluence API error response."""
216
+ try:
217
+ error_data = response.json()
218
+ # Confluence API returns errors in different formats
219
+ if "message" in error_data:
220
+ return error_data["message"]
221
+ if "errorMessages" in error_data and error_data["errorMessages"]:
222
+ return "; ".join(error_data["errorMessages"])
223
+ if "errors" in error_data:
224
+ errors = error_data["errors"]
225
+ if isinstance(errors, list):
226
+ return "; ".join(str(e) for e in errors)
227
+ if isinstance(errors, dict):
228
+ return "; ".join(f"{k}: {v}" for k, v in errors.items())
229
+ except Exception:
230
+ pass
231
+ return response.text or "Unknown error"
232
+
233
+ async def create_page(
234
+ self,
235
+ space_key: str,
236
+ title: str,
237
+ body_content: str,
238
+ parent_id: int | None = None,
239
+ ) -> ConfluencePage:
240
+ """
241
+ Create a new Confluence page in a specified space.
242
+
243
+ Args:
244
+ space_key: The key of the Confluence space where the page should live
245
+ title: The title of the new page
246
+ body_content: The content in Confluence Storage Format (XML) or raw text
247
+ parent_id: Optional ID of the parent page for creating a child page
248
+
249
+ Returns
250
+ -------
251
+ ConfluencePage with the created page data
252
+
253
+ Raises
254
+ ------
255
+ ConfluenceError: If space not found, parent page not found, duplicate title,
256
+ permission denied, or invalid content
257
+ httpx.HTTPStatusError: If the API request fails with unexpected status
258
+ """
259
+ cloud_id = await self._get_cloud_id()
260
+ url = f"{ATLASSIAN_API_BASE}/ex/confluence/{cloud_id}/wiki/rest/api/content"
261
+
262
+ payload: dict[str, Any] = {
263
+ "type": "page",
264
+ "title": title,
265
+ "space": {"key": space_key},
266
+ "body": {
267
+ "storage": {
268
+ "value": body_content,
269
+ "representation": "storage",
270
+ }
271
+ },
272
+ }
273
+
274
+ if parent_id is not None:
275
+ payload["ancestors"] = [{"id": parent_id}]
276
+
277
+ response = await self._client.post(url, json=payload)
278
+
279
+ if response.status_code == HTTPStatus.NOT_FOUND:
280
+ error_msg = self._extract_error_message(response)
281
+ if parent_id is not None and "ancestor" in error_msg.lower():
282
+ raise ConfluenceError(
283
+ f"Parent page with ID '{parent_id}' not found", status_code=404
284
+ )
285
+ raise ConfluenceError(
286
+ f"Space '{space_key}' not found or resource unavailable: {error_msg}",
287
+ status_code=404,
288
+ )
289
+
290
+ if response.status_code == HTTPStatus.CONFLICT:
291
+ raise ConfluenceError(
292
+ f"A page with title '{title}' already exists in space '{space_key}'",
293
+ status_code=409,
294
+ )
295
+
296
+ if response.status_code == HTTPStatus.FORBIDDEN:
297
+ raise ConfluenceError(
298
+ f"Permission denied: you don't have access to create pages in space '{space_key}'",
299
+ status_code=403,
300
+ )
301
+
302
+ if response.status_code == HTTPStatus.BAD_REQUEST:
303
+ error_msg = self._extract_error_message(response)
304
+ raise ConfluenceError(f"Invalid request: {error_msg}", status_code=400)
305
+
306
+ if response.status_code == HTTPStatus.TOO_MANY_REQUESTS:
307
+ raise ConfluenceError("Rate limit exceeded. Please try again later.", status_code=429)
308
+
309
+ response.raise_for_status()
310
+
311
+ return self._parse_response(response.json())
312
+
313
+ def _parse_comment_response(self, data: dict, page_id: str) -> ConfluenceComment:
314
+ """Parse API response into ConfluenceComment."""
315
+ body_content = ""
316
+ body = data.get("body", {})
317
+ if isinstance(body, dict):
318
+ storage = body.get("storage", {})
319
+ if isinstance(storage, dict):
320
+ body_content = storage.get("value", "")
321
+
322
+ return ConfluenceComment(
323
+ comment_id=str(data.get("id", "")),
324
+ page_id=page_id,
325
+ body=body_content,
326
+ )
327
+
328
+ async def add_comment(self, page_id: str, comment_body: str) -> ConfluenceComment:
329
+ """
330
+ Add a comment to a Confluence page.
331
+
332
+ Args:
333
+ page_id: The numeric page ID where the comment will be added
334
+ comment_body: The text content of the comment
335
+
336
+ Returns
337
+ -------
338
+ ConfluenceComment with the created comment data
339
+
340
+ Raises
341
+ ------
342
+ ConfluenceError: If page not found, permission denied, or invalid content
343
+ httpx.HTTPStatusError: If the API request fails with unexpected status
344
+ """
345
+ cloud_id = await self._get_cloud_id()
346
+ url = f"{ATLASSIAN_API_BASE}/ex/confluence/{cloud_id}/wiki/rest/api/content"
347
+
348
+ payload: dict[str, Any] = {
349
+ "type": "comment",
350
+ "container": {"id": page_id, "type": "page"},
351
+ "body": {
352
+ "storage": {
353
+ "value": comment_body,
354
+ "representation": "storage",
355
+ }
356
+ },
357
+ }
358
+
359
+ response = await self._client.post(url, json=payload)
360
+
361
+ if response.status_code == HTTPStatus.NOT_FOUND:
362
+ error_msg = self._extract_error_message(response)
363
+ raise ConfluenceError(
364
+ f"Page with ID '{page_id}' not found: {error_msg}",
365
+ status_code=404,
366
+ )
367
+
368
+ if response.status_code == HTTPStatus.FORBIDDEN:
369
+ raise ConfluenceError(
370
+ f"Permission denied: you don't have access to add comments to page '{page_id}'",
371
+ status_code=403,
372
+ )
373
+
374
+ if response.status_code == HTTPStatus.BAD_REQUEST:
375
+ error_msg = self._extract_error_message(response)
376
+ raise ConfluenceError(f"Invalid request: {error_msg}", status_code=400)
377
+
378
+ if response.status_code == HTTPStatus.TOO_MANY_REQUESTS:
379
+ raise ConfluenceError("Rate limit exceeded. Please try again later.", status_code=429)
380
+
381
+ response.raise_for_status()
382
+
383
+ return self._parse_comment_response(response.json(), page_id)
384
+
188
385
  async def __aenter__(self) -> "ConfluenceClient":
189
386
  """Async context manager entry."""
190
387
  return self
@@ -0,0 +1,248 @@
1
+ # Copyright 2025 DataRobot, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Google Drive API Client and utilities for OAuth."""
16
+
17
+ import logging
18
+ from typing import Annotated
19
+ from typing import Any
20
+
21
+ import httpx
22
+ from datarobot.auth.datarobot.exceptions import OAuthServiceClientErr
23
+ from fastmcp.exceptions import ToolError
24
+ from pydantic import BaseModel
25
+ from pydantic import ConfigDict
26
+ from pydantic import Field
27
+
28
+ from datarobot_genai.drmcp.core.auth import get_access_token
29
+
30
+ logger = logging.getLogger(__name__)
31
+
32
+ DEFAULT_FIELDS = "nextPageToken,files(id,name,size,mimeType,webViewLink,createdTime,modifiedTime)"
33
+ DEFAULT_ORDER = "modifiedTime desc"
34
+ MAX_PAGE_SIZE = 100
35
+ LIMIT = 500
36
+
37
+
38
+ async def get_gdrive_access_token() -> str | ToolError:
39
+ """
40
+ Get Google Drive OAuth access token with error handling.
41
+
42
+ Returns
43
+ -------
44
+ Access token string on success, ToolError on failure
45
+
46
+ Example:
47
+ ```python
48
+ token = await get_gdrive_access_token()
49
+ if isinstance(token, ToolError):
50
+ # Handle error
51
+ return token
52
+ # Use token
53
+ ```
54
+ """
55
+ try:
56
+ access_token = await get_access_token("google")
57
+ if not access_token:
58
+ logger.warning("Empty access token received")
59
+ return ToolError("Received empty access token. Please complete the OAuth flow.")
60
+ return access_token
61
+ except OAuthServiceClientErr as e:
62
+ logger.error(f"OAuth client error: {e}", exc_info=True)
63
+ return ToolError(
64
+ "Could not obtain access token for Google. Make sure the OAuth "
65
+ "permission was granted for the application to act on your behalf."
66
+ )
67
+ except Exception as e:
68
+ logger.error(f"Unexpected error obtaining access token: {e}", exc_info=True)
69
+ return ToolError("An unexpected error occurred while obtaining access token for Google.")
70
+
71
+
72
+ class GoogleDriveError(Exception):
73
+ """Exception for Google Drive API errors."""
74
+
75
+ def __init__(self, message: str) -> None:
76
+ super().__init__(message)
77
+
78
+
79
+ PrimitiveData = str | int | float | bool | None
80
+
81
+
82
+ class GoogleDriveFile(BaseModel):
83
+ """Represents a file from Google Drive."""
84
+
85
+ id: str
86
+ name: str
87
+ mime_type: Annotated[str, Field(alias="mimeType")]
88
+ size: int | None = None
89
+ web_view_link: Annotated[str | None, Field(alias="webViewLink")] = None
90
+ created_time: Annotated[str | None, Field(alias="createdTime")] = None
91
+ modified_time: Annotated[str | None, Field(alias="modifiedTime")] = None
92
+
93
+ model_config = ConfigDict(populate_by_name=True)
94
+
95
+ @classmethod
96
+ def from_api_response(cls, data: dict[str, Any]) -> "GoogleDriveFile":
97
+ """Create a GoogleDriveFile from API response data."""
98
+ return cls(
99
+ id=data.get("id", "Unknown"),
100
+ name=data.get("name", "Unknown"),
101
+ mime_type=data.get("mimeType", "Unknown"),
102
+ size=int(data["size"]) if data.get("size") else None,
103
+ web_view_link=data.get("webViewLink"),
104
+ created_time=data.get("createdTime"),
105
+ modified_time=data.get("modifiedTime"),
106
+ )
107
+
108
+
109
+ class PaginatedResult(BaseModel):
110
+ """Result of a paginated API call."""
111
+
112
+ files: list[GoogleDriveFile]
113
+ next_page_token: str | None = None
114
+
115
+
116
+ class GoogleDriveClient:
117
+ """Client for interacting with Google Drive API."""
118
+
119
+ def __init__(self, access_token: str) -> None:
120
+ self._client = httpx.AsyncClient(
121
+ base_url="https://www.googleapis.com/drive/v3/files",
122
+ headers={"Authorization": f"Bearer {access_token}"},
123
+ timeout=30.0,
124
+ )
125
+
126
+ async def list_files(
127
+ self,
128
+ page_size: int,
129
+ limit: int,
130
+ page_token: str | None = None,
131
+ query: str | None = None,
132
+ ) -> PaginatedResult:
133
+ """
134
+ List files from Google Drive.
135
+
136
+ It's public API for GoogleDriveClient.
137
+
138
+ Args:
139
+ page_size: Number of files to return per 1 gdrive api request.
140
+ limit: Maximum number of files to return.
141
+ page_token: Optional token (specific for gdrive api) allowing to query next page.
142
+ query: Optional query to filter results.
143
+ If not provided it'll list all authorized user files.
144
+ If the query doesn't contain operators (contains, =, etc.), it will be treated as
145
+ a name search: "name contains '{query}'".
146
+
147
+ Returns
148
+ -------
149
+ List of Google Drive files.
150
+ """
151
+ if page_size <= 0:
152
+ raise GoogleDriveError("Error: page size must be positive.")
153
+ if limit <= 0:
154
+ raise GoogleDriveError("Error: limit must be positive.")
155
+ if limit < page_size:
156
+ raise GoogleDriveError("Error: limit must be bigger than or equal to page size.")
157
+ if limit % page_size != 0:
158
+ raise GoogleDriveError("Error: limit must be multiplication of page size.")
159
+
160
+ page_size = min(page_size, MAX_PAGE_SIZE)
161
+ limit = min(limit, LIMIT)
162
+ fetched = 0
163
+
164
+ formatted_query = self._get_formatted_query(query)
165
+
166
+ files: list[GoogleDriveFile] = []
167
+
168
+ while fetched < limit:
169
+ data = await self._list_files(
170
+ page_size=page_size,
171
+ page_token=page_token,
172
+ query=formatted_query,
173
+ )
174
+ files.extend(data.files)
175
+ fetched += len(data.files)
176
+ page_token = data.next_page_token
177
+
178
+ if not page_token:
179
+ break
180
+
181
+ return PaginatedResult(files=files, next_page_token=page_token)
182
+
183
+ async def _list_files(
184
+ self,
185
+ page_size: int,
186
+ page_token: str | None = None,
187
+ query: str | None = None,
188
+ ) -> PaginatedResult:
189
+ """Fetch a page of files from Google Drive."""
190
+ params: dict[str, PrimitiveData] = {
191
+ "pageSize": page_size,
192
+ "fields": DEFAULT_FIELDS,
193
+ "orderBy": DEFAULT_ORDER,
194
+ }
195
+ if page_token:
196
+ params["pageToken"] = page_token
197
+ if query:
198
+ params["q"] = query
199
+
200
+ response = await self._client.get(url="/", params=params)
201
+ response.raise_for_status()
202
+ data = response.json()
203
+
204
+ files = [
205
+ GoogleDriveFile.from_api_response(file_data) for file_data in data.get("files", [])
206
+ ]
207
+ next_page_token = data.get("nextPageToken")
208
+ return PaginatedResult(files=files, next_page_token=next_page_token)
209
+
210
+ @staticmethod
211
+ def _get_formatted_query(query: str | None) -> str | None:
212
+ """Get formatted Google Drive API query.
213
+
214
+ Args:
215
+ query: Optional search query string (e.g., "name contains 'report'"").
216
+ If the query doesn't contain operators (contains, =, etc.), it will be treated as
217
+ a name search: "name contains '{query}'".
218
+
219
+ Returns
220
+ -------
221
+ Correctly formatted query (if provided)
222
+ """
223
+ if not query:
224
+ return None
225
+
226
+ # If query doesn't look like a formatted query (no operators), format it as a name search
227
+ # Check if query already has Google Drive API operators
228
+ has_operator = any(
229
+ op in query for op in [" contains ", "=", "!=", " in ", " and ", " or ", " not "]
230
+ )
231
+ formatted_query = query
232
+ if not has_operator and query.strip():
233
+ # Simple text search - format as name contains query
234
+ # Escape backslashes first, then single quotes for Google Drive API
235
+ escaped_query = query.replace("\\", "\\\\").replace("'", "\\'")
236
+ formatted_query = f"name contains '{escaped_query}'"
237
+ logger.debug(f"Auto-formatted query '{query}' to '{formatted_query}'")
238
+ return formatted_query
239
+
240
+ async def __aenter__(self) -> "GoogleDriveClient":
241
+ """Async context manager entry."""
242
+ return self
243
+
244
+ async def __aexit__(
245
+ self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: Any
246
+ ) -> None:
247
+ """Async context manager exit."""
248
+ await self._client.aclose()
@@ -25,6 +25,18 @@ from .atlassian import get_atlassian_cloud_id
25
25
 
26
26
  logger = logging.getLogger(__name__)
27
27
 
28
+ RESPONSE_JIRA_ISSUE_FIELDS = {
29
+ "id",
30
+ "key",
31
+ "summary",
32
+ "status",
33
+ "reporter",
34
+ "assignee",
35
+ "created",
36
+ "updated",
37
+ }
38
+ RESPONSE_JIRA_ISSUE_FIELDS_STR = ",".join(RESPONSE_JIRA_ISSUE_FIELDS)
39
+
28
40
 
29
41
  class _IssuePerson(BaseModel):
30
42
  email_address: str = Field(alias="emailAddress")
@@ -107,10 +119,41 @@ class JiraClient:
107
119
  self._cloud_id = await get_atlassian_cloud_id(self._client, service_type="jira")
108
120
  return self._cloud_id
109
121
 
110
- async def _get_full_url(self, url: str) -> str:
122
+ async def _get_full_url(self, path: str) -> str:
111
123
  """Return URL for Jira API."""
112
124
  cloud_id = await self._get_cloud_id()
113
- return f"{ATLASSIAN_API_BASE}/ex/jira/{cloud_id}/rest/api/3/{url}"
125
+ return f"{ATLASSIAN_API_BASE}/ex/jira/{cloud_id}/rest/api/3/{path}"
126
+
127
+ async def search_jira_issues(self, jql_query: str, max_results: int) -> list[Issue]:
128
+ """
129
+ Search Jira issues using JQL (Jira Query Language).
130
+
131
+ Args:
132
+ jql_query: JQL Query
133
+ max_results: Maximum number of issues to return
134
+
135
+ Returns
136
+ -------
137
+ List of Jira issues
138
+
139
+ Raises
140
+ ------
141
+ httpx.HTTPStatusError: If the API request fails
142
+ """
143
+ url = await self._get_full_url("search/jql")
144
+ response = await self._client.post(
145
+ url,
146
+ json={
147
+ "jql": jql_query,
148
+ "fields": list(RESPONSE_JIRA_ISSUE_FIELDS),
149
+ "maxResults": max_results,
150
+ },
151
+ )
152
+
153
+ response.raise_for_status()
154
+ raw_issues = response.json().get("issues", [])
155
+ issues = [Issue(**issue) for issue in raw_issues]
156
+ return issues
114
157
 
115
158
  async def get_jira_issue(self, issue_key: str) -> Issue:
116
159
  """
@@ -128,9 +171,7 @@ class JiraClient:
128
171
  httpx.HTTPStatusError: If the API request fails
129
172
  """
130
173
  url = await self._get_full_url(f"issue/{issue_key}")
131
- response = await self._client.get(
132
- url, params={"fields": "id,key,summary,status,reporter,assignee,created,updated"}
133
- )
174
+ response = await self._client.get(url, params={"fields": RESPONSE_JIRA_ISSUE_FIELDS_STR})
134
175
 
135
176
  if response.status_code == HTTPStatus.NOT_FOUND:
136
177
  raise ValueError(f"{issue_key} not found")
@@ -209,6 +250,79 @@ class JiraClient:
209
250
  jsoned = response.json()
210
251
  return jsoned["key"]
211
252
 
253
+ async def update_jira_issue(self, issue_key: str, fields: dict[str, Any]) -> list[str]:
254
+ """
255
+ Update Jira issue.
256
+
257
+ Args:
258
+ issue_key: The key of the Jira issue, e.g., 'PROJ-123'
259
+ fields: A dictionary of field names and their new values
260
+ e.g., {'description': 'New content'}
261
+
262
+ Returns
263
+ -------
264
+ List of updated fields
265
+
266
+ Raises
267
+ ------
268
+ httpx.HTTPStatusError: If the API request fails
269
+ """
270
+ url = await self._get_full_url(f"issue/{issue_key}")
271
+ payload = {"fields": fields}
272
+
273
+ response = await self._client.put(url, json=payload)
274
+
275
+ response.raise_for_status()
276
+ return list(fields.keys())
277
+
278
+ async def get_available_jira_transitions(self, issue_key: str) -> dict[str, str]:
279
+ """
280
+ Get Available Jira Transitions.
281
+
282
+ Args:
283
+ issue_key: The key of the Jira issue, e.g., 'PROJ-123'
284
+
285
+ Returns
286
+ -------
287
+ Dictionary where key is the transition name and value is the transition ID
288
+
289
+ Raises
290
+ ------
291
+ httpx.HTTPStatusError: If the API request fails
292
+ """
293
+ url = await self._get_full_url(f"issue/{issue_key}/transitions")
294
+ response = await self._client.get(url)
295
+ response.raise_for_status()
296
+ jsoned = response.json()
297
+ transitions = {
298
+ transition["name"]: transition["id"] for transition in jsoned.get("transitions", [])
299
+ }
300
+ return transitions
301
+
302
+ async def transition_jira_issue(self, issue_key: str, transition_id: str) -> None:
303
+ """
304
+ Transition Jira issue.
305
+
306
+ Args:
307
+ issue_key: The key of the Jira issue, e.g., 'PROJ-123'
308
+ transition_id: Id of target transitionm e.g. '123'.
309
+ Can be obtained from `get_available_jira_transitions`.
310
+
311
+ Returns
312
+ -------
313
+ Nothing
314
+
315
+ Raises
316
+ ------
317
+ httpx.HTTPStatusError: If the API request fails
318
+ """
319
+ url = await self._get_full_url(f"issue/{issue_key}")
320
+ payload = {"transition": {"id": transition_id}}
321
+
322
+ response = await self._client.post(url, json=payload)
323
+
324
+ response.raise_for_status()
325
+
212
326
  async def __aenter__(self) -> "JiraClient":
213
327
  """Async context manager entry."""
214
328
  return self