Skip to content

Commit bc91b9e

Browse files
committed
fixup! fixup! jira
wip
1 parent f707f3e commit bc91b9e

File tree

8 files changed

+77
-35
lines changed

8 files changed

+77
-35
lines changed

examples/jira/python/jira_endpoints.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ def _safe_get(obj, key, default=None):
147147
"name": _safe_get(fields.get('project'), 'name')
148148
},
149149
"parent": _safe_get(fields.get('parent'), 'key'),
150-
"url": f"{jira_url}/browse/{issue.get('key')}",
151-
"self": issue.get('self')
150+
"url": f"{jira_url}/browse/{issue.get('key')}"
152151
}
153152

154153
return cleaned_issue
@@ -162,7 +161,7 @@ def get_user(account_id: str) -> Dict[str, Any]:
162161
Example: "557058:ab168c94-8485-405c-88e6-6458375eb30b"
163162
164163
Returns:
165-
Dictionary containing the user details
164+
Dictionary containing filtered user details
166165
167166
Raises:
168167
ValueError: If user is not found or account ID is invalid
@@ -172,7 +171,15 @@ def get_user(account_id: str) -> Dict[str, Any]:
172171

173172
# Get user by account ID - pass as account_id parameter for Jira Cloud
174173
user = jira.user(account_id=account_id)
175-
return user
174+
175+
# Return only the requested fields
176+
return {
177+
"accountId": user.get("accountId"),
178+
"displayName": user.get("displayName"),
179+
"emailAddress": user.get("emailAddress"),
180+
"active": user.get("active"),
181+
"timeZone": user.get("timeZone")
182+
}
176183

177184

178185
def search_user(query: str) -> List[Dict[str, Any]]:
@@ -183,15 +190,29 @@ def search_user(query: str) -> List[Dict[str, Any]]:
183190
Examples: "ben@raw-labs.com", "Benjamin Gaidioz", "ben", "benjamin", "gaidioz"
184191
185192
Returns:
186-
List of matching users. Empty list if no matches found.
193+
List of matching users with filtered fields. Empty list if no matches found.
187194
"""
188195
logger.info("Searching for users with query: %s", query)
189196
jira = _get_jira_client()
190197

191198
# user_find_by_user_string returns a list of users matching the query
192199
users = jira.user_find_by_user_string(query=query)
193200

194-
return users or []
201+
if not users:
202+
return []
203+
204+
# Filter users to only include relevant fields
205+
filtered_users = []
206+
for user in users:
207+
filtered_users.append({
208+
"accountId": user.get("accountId"),
209+
"displayName": user.get("displayName"),
210+
"emailAddress": user.get("emailAddress"),
211+
"active": user.get("active"),
212+
"timeZone": user.get("timeZone")
213+
})
214+
215+
return filtered_users
195216

196217

197218
def list_projects() -> List[Dict[str, Any]]:
@@ -203,7 +224,7 @@ def list_projects() -> List[Dict[str, Any]]:
203224
logger.info("Listing all projects")
204225

205226
jira = _get_jira_client()
206-
raw_projects: List[Dict[str, Any]] = jira.projects()
227+
raw_projects: List[Dict[str, Any]] = jira.projects(expand="lead")
207228

208229
def safe_name(obj: Optional[Dict[str, Any]]) -> Optional[str]:
209230
return obj.get("displayName") or obj.get("name") if obj else None
@@ -303,8 +324,7 @@ def get_project_roles(project_key: str) -> List[Dict[str, Any]]:
303324

304325
result.append({
305326
"name": role_name,
306-
"id": role_id,
307-
"url": role_url
327+
"id": role_id
308328
})
309329

310330
return result

examples/jira/tools/get_issue.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ tool:
106106
url:
107107
type: string
108108
description: The issue URL
109-
self:
110-
type: string
111-
description: The API self link
112109
tests:
113110
- name: "Get issue by key"
114111
description: "Verify issue retrieval returns expected structure"

examples/jira/tools/get_project_roles.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ tool:
3737
id:
3838
type: string
3939
description: The role ID
40-
url:
41-
type: string
42-
description: The role URL
4340
tests:
4441
- name: "Get project roles"
4542
description: "Verify project roles returns array of roles"

examples/jira/tools/get_user.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ tool:
4242
active:
4343
type: boolean
4444
description: Whether the user is active
45-
self:
45+
timeZone:
4646
type: string
47-
description: The API self link
47+
description: The user's time zone
4848
tests:
4949
- name: "Get user by account ID"
5050
description: "Just run the tool"

examples/jira/tools/jql_query.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ tool:
4545
If not specified, returns all matching results.
4646
Recommended to use with start parameter for pagination.
4747
examples: [50, 100, 200]
48+
default: null
4849
return:
4950
type: array
5051
items:

examples/jira/tools/search_user.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ tool:
4545
active:
4646
type: boolean
4747
description: Whether the user is active
48-
self:
48+
timeZone:
4949
type: string
50-
description: The API self link
50+
description: The user's time zone
5151
tests:
5252
- name: "Search by name"
5353
description: "Verify user search by name returns results"

examples/salesforce/python/salesforce_endpoints.py

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,32 @@ def search(search_term: str) -> List[Dict[str, Any]]:
9999
return sosl(sosl_query)
100100

101101

102-
def list_sobjects() -> List[str]:
103-
"""Get a list of all available Salesforce objects.
102+
def list_sobjects(filter: Optional[str] = None) -> List[str]:
103+
"""List all available Salesforce objects (sObjects) in the org.
104+
105+
Args:
106+
filter: Optional fuzzy filter to match object names (case-insensitive substring search).
107+
Examples: "account", "__c" for custom objects, "contact", etc.
104108
105109
Returns:
106-
List of object names from the org
107-
108-
Example:
109-
>>> list_sobjects() # Returns ['Account', 'Contact', ...]
110+
list: List of Salesforce object names as strings
110111
"""
111-
logger.info("Listing all Salesforce objects")
112-
113112
sf = _get_salesforce_client()
114-
return [obj['name'] for obj in sf.describe()['sobjects']]
113+
114+
describe_result = sf.describe()
115+
116+
object_names = [obj['name'] for obj in describe_result['sobjects']]
117+
118+
if filter is not None and filter.strip():
119+
filter_lower = filter.lower()
120+
object_names = [
121+
name for name in object_names
122+
if filter_lower in name.lower()
123+
]
124+
125+
object_names.sort()
126+
127+
return object_names
115128

116129

117130
def describe_sobject(sobject_name: str) -> Dict[str, Any]:
@@ -156,11 +169,6 @@ def describe_sobject(sobject_name: str) -> Dict[str, Any]:
156169

157170
return fields_info
158171

159-
160-
161-
return result
162-
163-
164172
def get_sobject(sobject_name: str, record_id: str) -> Dict[str, Any]:
165173
"""Get a specific Salesforce object by its ID.
166174
@@ -177,6 +185,17 @@ def get_sobject(sobject_name: str, record_id: str) -> Dict[str, Any]:
177185
logger.info("Getting Salesforce object: %s with ID: %s", sobject_name, record_id)
178186

179187
sf = _get_salesforce_client()
180-
result = sf.__getattr__(sobject_name).get(record_id)
188+
189+
# Try to get the object - catch this specifically for "object doesn't exist"
190+
try:
191+
sobject = getattr(sf, sobject_name)
192+
except AttributeError:
193+
raise Exception(f"Salesforce object '{sobject_name}' does not exist")
194+
195+
result = sobject.get(record_id)
196+
197+
# Remove 'attributes' field for consistency with other functions
198+
if isinstance(result, dict) and 'attributes' in result:
199+
result = {k: v for k, v in result.items() if k != 'attributes'}
181200

182201
return result

examples/salesforce/tools/list_sobjects.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ tool:
66
language: python
77
source:
88
file: ../python/salesforce_endpoints.py
9-
parameters: []
9+
parameters:
10+
- name: filter
11+
type: string
12+
description: "Optional fuzzy filter to match object names (case-insensitive substring search). Examples: 'account', '__c' for custom objects, 'contact', etc. If not provided, all objects are returned."
13+
examples:
14+
- "account"
15+
- "__c"
16+
- "contact"
17+
default: null
1018
return:
1119
type: array
1220
items:

0 commit comments

Comments
 (0)